简体   繁体   English

类库(可用于Universal Apps移植)System.Threading.Thread的限制

[英]Class Library (Portable for Universal Apps) System.Threading.Thread limitations

I use Visual Studio 2013 Ultimate Update 4 to create a new project of type "Class Library (Portable for Universal Apps)". 我使用Visual Studio 2013 Ultimate Update 4创建类型为“类库(可移植到Universal Apps)”的新项目。 The resulting PCL is targeted at two platforms ie Windows 8.1 and Windows Phone 8.1 and this is what I need. 生成的PCL针对两个平台,即Windows 8.1和Windows Phone 8.1,这就是我所需要的。

System.Threading.Thread class is not supported in this subset. 此子集不支持System.Threading.Thread类。 When I widen the assembly targeting with two more platforms (.NET Framework 4.5.1 and Silverlight 5) the System.Threading.Thread mystically shows up and becomes available. 当我使用另外两个平台(.NET Framework 4.5.1和Silverlight 5)扩大程序集目标时,System.Threading.Thread神秘地显示出来并可用。 I tried to use it and it works perfectly being run by both Windows.Phone 8.1 and Windows 8.1 Store apps. 我尝试使用它,它可以完美地在Windows.Phone 8.1和Windows 8.1 Store应用程序上运行。

Did I get it right that the System.Threading.Thread class is simply hidden from the "default" PCL configuration in order to push developers towards async/await pattern? 我是否正确地将System.Threading.Thread类从“默认” PCL配置中隐藏起来,以将开发人员推向异步/等待模式?

Leaving behind the comparison of advantages and draws of different asynchronous execution and thread management models, are there any technical drawbacks in utilizing the System.Threading.Thread class in the mentioned scenario? 撇开不同异步执行和线程管理模型的优点和缺点进行比较之后,在上述情况下利用System.Threading.Thread类是否存在技术上的弊端?

Thanks in advance. 提前致谢。

After some discussion with David Kean from the .NET team, this is expected behaviour but note that you do not get access to the full .NET Thread class; 在与.NET团队的David Kean进行了讨论之后,这是预期的行为,但是请注意,您无法访问完整的.NET Thread类。 you only get a couple of things like ManagedThreadId and CurrentUICulture . 您只会得到诸如ManagedThreadIdCurrentUICulture类的东西。

So you still need to use either the thread pool or the task-based APIs in order to run parallel operations. 因此,您仍然需要使用线程池或基于任务的API来运行并行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM