Forms, threading and Frustration

In Visual Studio 2005, if you have a windows form and have a fair amount of threading going then that things can get pretty frustrating. As you know, because of the way that Windows handles its user interface, you should only be updating the user interface from the main thread. If you try to do it on other threads, bad things happen, and they can be pretty hard to track down. Windows forms includes some code to detect when that is happening, but it can’t do it in all cases. When you get in this situation, you need to call Invoke() on the form, and pass it a delegate to the function that you want to be called on the main thread. Eric discusses this in detail which is a recommended read if you play with a lot of threads on your Win Forms.

Published by

Amit Bahree

This blog is my personal blog and while it does reflect my experiences in my professional life, this is just my thoughts. Most of the entries are technical though sometimes they can vary from the wacky to even political – however that is quite rare. Quite often, I have been asked what’s up with the “gibberish” and the funny title of the blog? Some people even going the extra step to say that, this is a virus that infected their system (ahem) well. [:D] It actually is quite simple, and if you have still not figured out then check out this link – whats in a name?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.