Monday, September 1, 2008

Don't forget to call EndXxx()

Don't forget to call EndXxx() if initialized an asynchronous call via BeginXxx(), otherwise there will be resource leaks. I did forget to do this in post: [Multi-Threading] Syncing between Threads by SynchronizationContext .

EndXxx() usually should be called before you want to get the result of the asynchronous operation. You can call it right after BeginXxx(), or when you get noticed about the completion of the asynchronous operation. But remember, you should call it only for one time. If you call it the second time, the behaviour are not predicatible since resources have been released during the first call to EndXxx().

No comments: