The MSDN文档说Thread.Sleep()
可以用在portable类库。编译器另有说明。除了自旋循环之外,我还有什么选择?Thread.CurrentThread.Join()
也不存在。
项目文件:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C46B138E-CC30-4397-B326-8DD019E3874B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>x0xtest.AVR</RootNamespace>
<AssemblyName>x0xtest.AVR</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile3</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Attributes\AddressAttribute.cs" />
<Compile Include="Attributes\RegAttribute.cs" />
<Compile Include="Attributes\ROAttribute.cs" />
<Compile Include="Attributes\RWAttribute.cs" />
<Compile Include="Attributes\WOAttribute.cs" />
<Compile Include="Devices\ATMega162.cs" />
<Compile Include="Exceptions.cs" />
<Compile Include="IntelHexFormat.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Proxy.cs" />
<Compile Include="ProxyBase.cs" />
<Compile Include="ProxyBase_UploadFirmware.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\x0xtest.Comm\x0xtest.Comm.csproj">
<Project>{F78547AC-1CA1-4ADB-9FA8-3E7DEB682240}</Project>
<Name>x0xtest.Comm</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
这就是“便携”的不幸的副作用。通过减法,库变得高度可移植,删除了许多可能目标之一上不可用的所有部分。这对 Thread 类造成了严重破坏,它完全没有任何有用的成员。只剩下 5 个:MemoryBarrier()、CurrentCulture、CurrentThread、CurrentUICulture 和 ManagedThreadId。
这可能看起来很奇怪,广告目标的交集肯定支持更多。这可能与未宣传的内容有关。即将推出的 Windows 8 版本将在 ARM 内核上运行。也称为 WinRT 或 Metro 或“.NET for Metro 风格应用程序”API,具体取决于您使用的工具。 WinRT 严重削减了传统的 Windows API,其 System.Windows.Threading 命名空间相当空。
这将生成一个ton关于“一周,现在我该怎么办”之类的问题。这里可能的解决方法是烧掉一个虚拟的 System.Threading.ManualResetEvent 对象。它有一个 WaitOne(TimeSpan) 方法。
Fwiw,我个人并不期待针对这个库进行编程。到目前为止,最令人震惊的花絮是您提供的链接的问答部分:
问:我想问一下Compile方法是怎么回事
System.Linq.Expressions.Expression 类。
答:Windows Phone/Xbox 不支持它,因此仅当您面向 Silverlight + .NET 时才会显示。
哎哟。便携、运动。这个需要炖一会儿。我对 DevDiv 表示同情,特别是 David Kean,这是一项艰巨的工作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)