Nonblocking sleep in C#5.0 (like setTimeout in JavaScript)
AsyncCTP has TaskEx.Delay
. This wraps timers in your task. Note, that this is not production-ready code. TaskEx
will be merged into Task
when C# 5 arrives.
private static async Task ReturnItAsync(string it, Action<string> callback)
{
await TaskEx.Delay(1000);
callback(it);
}
Or if you want to return it
:
private static async Task<string> ReturnItAsync(string it, Func<string, string> callback)
{
await TaskEx.Delay(1000);
return callback(it);
}