Thread.Sleep() in a Portable Class Library

前端 未结 5 2056
长发绾君心
长发绾君心 2021-02-18 15:05

The MSDN docs say Thread.Sleep() can be used in a portable class library. The compiler says otherwise. What are my alternatives besides a spin-loo

5条回答
  •  你的背包
    2021-02-18 15:44

    (I 'own' the portable library project at Microsoft)

    Unfortunately, this was a late change to the Portable Library project surface area that we made so that we could run and be referenced by Metro apps. One of the new things with Metro style apps, Visual Studio 11, and Windows 8 is to remove the need for apps to create and control their own threads (which is tough to get right). Instead, the idea is that you make use of language (ie async/await) and framework features (Task) to perform and synchronize with operations that should occur in the background.

    What to use as a replacement (for example, ManualResetEvent, Task.Delay) , entirely depends on your scenario and what platforms you are targeting. Can you explain what you are doing?

提交回复
热议问题