Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2006

Tip: Looking for answers? Try searching our database.

Control.Invoke call hangs worker thread

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joe - 24 Mar 2006 17:10 GMT
I've spent the last couple of weeks trying to get to the bottom of a thread
that hangs.  We have a form-based application that updates some data once per
minute using a System.Threading.Timer.  Inside the spawned thread, we are
using Control.Invoke to call methods on home grown objects.  After running
for anywhere from several hours to a day, we see the data update thread hang
at one of these Control.Invoke calls.  Using WinDbg, we have determined it is
not a deadlock because we can see that only one thread has a lock.  Further,
that thread appears to be stuck on a WaitOneNative call that apparently
happens as part of the Invoke process.  It is important to note that we have
seen the Invoke call hang when calling empty (noop) methods on our objects as
well as methods that contain code.  Here is a stack trace of the offending
thread:

0x039ecb5c  0x7c90eb94 [FRAME: ECallMethodFrame] [DEFAULT] Boolean
System.Threading.WaitHandle.WaitOneNative(I,UI4,Boolean)
0x039ecb70  0x799ef0b7 [DEFAULT] [hasThis] Boolean
System.Threading.WaitHandle.WaitOne()
0x039ecba4  0x7b853fc4 [DEFAULT] [hasThis] Object
System.Windows.Forms.Control.MarshaledInvoke(Class
System.Windows.Forms.Control,Class System.Delegate,SZArray Object,Boolean)
0x039ecc48  0x7b881b19 [DEFAULT] [hasThis] Object
System.Windows.Forms.Control.Invoke(Class System.Delegate,SZArray Object)
0x039ecc58  0x7b881ae2 [DEFAULT] [hasThis] Object
System.Windows.Forms.Control.Invoke(Class System.Delegate)
0x039ecc5c  0x08fa5cad [DEFAULT] [hasThis] Void
Manager.Dashboard.UpdateWxData(Object)
 at [+0x5c55] [+0x2217] Dashboard.cs:2289
0x039eeed4  0x02cb335d [DEFAULT] [hasThis] Void
Manager.Dashboard.timerWx_Tick(Object)
 at [+0x18d] [+0xc6] Dashboard.cs:16707566
Naveen - 25 Mar 2006 02:48 GMT
It could probably be illegal cross thread operation. If you are using
Whidbey this can be easily identified by running under debug mode.
Whidbey uses MDA (Managed Debugging Assistant) to warn you on this.
MDA's are turned of in release builds. Also look at the !dae on the
memory dump to check if there are SEHExceptions which can help you
identifying any illegal cross thread operation.
William Stacey [MVP] - 25 Mar 2006 04:17 GMT
Did you try Control.BeginInvoke to see if it still happens as just a test?
Invoke is a blocking call, so if the UI thread is blocked on something else,
your worker will block waiting for result.  In this way, your worker and UI
could dead-lock each other.  How fast is the Timer going off?  Could you
provide a small sample to repo the issue?

Signature

William Stacey [MVP]

| I've spent the last couple of weeks trying to get to the bottom of a thread
| that hangs.  We have a form-based application that updates some data once per
[quoted text clipped - 26 lines]
| Manager.Dashboard.timerWx_Tick(Object)
|  at [+0x18d] [+0xc6] Dashboard.cs:16707566
hawk - 27 Mar 2006 12:23 GMT
Thanks for your reply.  In addition to posting here, I contacted Microsoft
Technical Support by phone.  After examining a WinDbg dump they confirmed
that the problem is the one explained in the following article:

http://support.microsoft.com/kb/896665/en-us

> Did you try Control.BeginInvoke to see if it still happens as just a test?
> Invoke is a blocking call, so if the UI thread is blocked on something else,
[quoted text clipped - 39 lines]
> | Manager.Dashboard.timerWx_Tick(Object)
> |  at [+0x18d] [+0xc6] Dashboard.cs:16707566

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.