Wednesday, November 27, 2013

.net 4.5: Thread.Sleep vs Task.Delay

Blocking is "out", "Async" is "in" with .NET 4.5
and and PCL (Portable Class Library)

c# - Thread.Sleep replacement in .NET for Windows Store - Stack Overflow
Windows Store apps embrace asynchrony - and an "asynchronous pause" is provided by Task.Delay. So within an asynchronous method, you'd write:
await Task.Delay(TimeSpan.FromSeconds(30));
... or whatever delay you want. The asynchronous method will continue 30 seconds later, but the thread will not be blocked, just as for all await expressions.
Behind the simplified syntax is a timer, so there is some overhead.
It just from one place (theread/OS) to another (generated code).
Price of progress...

Smoothie Charts: A JavaScript Charting Library for Streaming Data

Smoothie Charts: A JavaScript Charting Library for Streaming Data:
"A JavaScript Charting Library for Streaming Data"