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
(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?