Threading issue with VB.NET Default Instances
This post has been moved to my personal blog: Tobin Titus
Comments
Anonymous
April 20, 2006
The comment has been removedAnonymous
April 20, 2006
Bill, as always, your smallest contributions typically make me laugh the most. Thanks dude! :)Anonymous
May 15, 2006
Thank you, very good explanation. I have been trying to figure this out for a while now. What really threw me off was that the .Text was updating in the debuggin watch window. So i spent my time trying .Refresh() etc...
-Thanks, AAnonymous
June 19, 2006
Bless you, my son! My use of invoke was causing my application to hang if the desktop was locked and unlocked, and this solved that problem.Anonymous
June 19, 2006
No problem at all Tony. I'm glad it worked for you.Anonymous
June 26, 2006
I couldn't figure out why my textbox wasn't updating. Everything makes so much sense now!
Thank you a lot!Anonymous
July 11, 2006
Glad you enjoyed it Marky. Good luck.Anonymous
March 09, 2007
Great post, i have solved my problem. Thanks a lot.Anonymous
June 19, 2007
The comment has been removedAnonymous
July 13, 2007
The comment has been removedAnonymous
August 03, 2007
Thanks goodness someone understands this stuff. You have saved yet another .NET weakling from a slow lingering death, racking their brains to find out why , oh WHY isn't this control updating?Anonymous
August 20, 2007
Very neat! I had the same wacky problem too. Since I only have one form I used .OpenForms(0) instead in my app.Anonymous
September 04, 2007
Excellent.. this solved my problem with updating my form from my ManagementEventWatcher! Thanks!Anonymous
January 30, 2008
If your using multiple threads you will get a first chance exception thrown if two threads want to update the same form. Use this code to check to see if you successfully pulled a reference to your form, Public Sub UpdateStatusLabel(ByVal strMessage As String()) Try Dim f As Form1 = My.Forms.Form1.ActiveForm If f.ActiveForm Is Nothing Then Debug.Write("Nothing" & vbNewLine) Else f.Invoke(New UpdateStatusLabelHandler(AddressOf f.UpdateStatusLabelMethod), _ New Object() {strMessage}) End If Catch ex As Exception End Try End SubAnonymous
May 15, 2008
Thank you so much!!! I had a similar problem but mine was obfuscated by 3 levels of events and a module. After definitely diagnosing the problem as a separate instance of my form, I went searching for answers and eventually found your article, and realized I was calling the default instance of the form! Again, thanks for your clear explanation of a complicated problem. -RossAnonymous
October 05, 2008
The comment has been removedAnonymous
November 20, 2008
Thank you Tobin! It is working perfectly! Regards form Slovakia.Anonymous
February 11, 2009
Thanks for your explanation. I was trying to figure that out for about 2 hours :) Greets from Latvia :)Anonymous
March 23, 2009
Thank you, thank you, thank you! This has been driving me mad!Anonymous
April 07, 2009
More thanks...I had tired numerous google search postings on vb.net threading and this is the only one that actually worked. All the others would have some sort of fatal flaw that caused run time errors or just plain would not compile. Even on the code posted on MSDN for VS 2005(which is what I am using) failed. With this code, I have a program as a basis for learning about threading. Thanks again!Anonymous
April 16, 2009
Just want to say thanks for explaining the solution to a problem that has wasted a lot of time so far this afternoon, and would have wasted a lot more were it not for your post!Anonymous
December 21, 2009
Thanks Tobin! Been googling for a over day for a solution for this problem!Anonymous
January 10, 2010
Thanks a ton! Now how do you determine if the current thread is the main form or not.