Eric's Blog

Day to day experience in .NET
Welcome to Blogs @ IRM Sign in | Join | Help
 Search

Disclaimer

The content of this site is my own personal opinion and does not in any way represent my employer, it's subsideries or affiliates. These postings are provided "AS IS" with no warranties, and confer no rights.

This Blog

Team System Unit Test and Multithreading

With delegates it is quit easy to create a couple of asynchronous method calls and then wait for them all to finish. An alternative is to get a callback when the call finish, but that is not always the best solution. For example, if you have a web service where you want to make a call to your own database and another call to another web service you will save a lot of time by doing them in parallel and wait for both to finish and then return the result to the calling client.
When you wait for the calls to finish you typically use WaitHandle.WaitAll. The problem with this, when running this code through a unit test, is that WaitAll is not allowed for single thread apartment (STA). We have used a workaround for this by checking if we have compiled for DEBUG we only call WaitHandle.WaitAny and taking a potential wait when calling the first EndInvoke. A problem with this is that it will not be possible to run the unit tests when the code is compiled for RELEASE.
Published den 17 mars 2006 14:44 by ericqu
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 
Submit
Powered by Community Server, by Telligent Systems