views:

508

answers:

1

I'm looking for a design pattern to switch from using a ManualResetEvent to using Thread methods like Thread.Join. Right now I'm making an async call and then using a ManualResetEvent to wait till the async call finishes before continuing on the thread that made the call.

I'd be glad for any implementation that would produce more stable and legible code. Would be interested to see implementations using C# yield keyword and also F# Async if any.

Thanks.

+1  A: 

Have a look at Jeff Richter PowerThreading library available here. This library has AsyncEnumerator class which leverages 'yield' keyword for performing async operations in a synchrous manner.

There is a screencast about this class, available here:

http://channel9.msdn.com/posts/Charles/Jeffrey-Richter-and-his-AsyncEnumerator/

Hope this helps.

Valve.

Valentin Vasiliev