Ale*_*sky 22 c# portable-class-library
在MSDN文档说Thread.Sleep()可以被用在便携式类库.编译器说不然.除旋转循环外,我的其他选择是什么?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>
Run Code Online (Sandbox Code Playgroud)
Han*_*ant 25
这是"便携式"的不幸副作用.通过减法,库变得非常便携,删除了许多可能目标中的一个上不可用的所有部分.这对Thread类造成了严重破坏,它完全没有任何有用的成员.其中只有5个,MemoryBarrier(),CurrentCulture,CurrentThread,CurrentUICulture和ManagedThreadId.
这可能看起来很奇怪,广告目标的交集当然支持更多.这可能与未广告的相关.即将推出的将在ARM内核上运行的Windows 8版本.另外称为WinRT或Metro或".NET for Metro style apps"API,具体取决于您使用的工具.WinRT严重削减了传统的Windows API,其System.Windows.Threading命名空间非常空.
这将产生大量关于SO的问题,"Eeek,现在我该做什么".这里可能的解决方法是刻录一个虚拟的System.Threading.ManualResetEvent对象.它有一个WaitOne(TimeSpan)方法.
Fwiw,我个人并不期待对这个图书馆进行编程.到目前为止,最惊人的消息是在您提供的链接的问答部分:
问:我想问一下System.Linq.Expressions.Expression类的Compile方法有什么用.
答:Windows Phone/Xbox不支持它,因此只有在您定位Silverlight + .NET时才会显示.
哎哟.便携,可运动.这需要炖一段时间.我对DevDiv以及特别是David Kean的同情,艰难的工作表示同情.
Dav*_*ean 19
(我'拥有'微软的便携式图书馆项目)
不幸的是,这是对我们制作的可移植库项目表面区域的最新更改,以便我们可以运行并由Metro应用程序引用.Metro风格应用程序,Visual Studio 11和Windows 8的新功能之一是消除了创建和控制自己的线程的应用程序的需求(这很难做到正确).相反,我们的想法是您使用语言(即async/ await)和框架功能(Task)来执行应该在后台执行的操作并与之同步.
作为替代使用什么(例如ManualResetEvent,Task.Delay),完全取决于你的情况,你的目标是什么平台.你能解释一下你在做什么吗?
And*_*ner 18
System.Threading.Tasks.Task.Delay(ms).Wait();
Run Code Online (Sandbox Code Playgroud)
作为替代品的替代品
System.Threading.Thread.Sleep(ms);
Run Code Online (Sandbox Code Playgroud)
这在移植遗留代码库时工作正常.
| 归档时间: |
|
| 查看次数: |
12330 次 |
| 最近记录: |