PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
Re: using async in windows forms
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
Re: using async in windows forms
![]() |
Re: using async in windows forms |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
John,
Like Jakob said, it sounds like the child dialog is created on another thread since BeginInvoke executes the specified delegate on the ThreadPool. You can't create, access, or modify a windows Form or Control from a thread other than the main UI thread. The reason the child dialog appears to freeze is because the thread it was created on does not have a message loop running on it. The reason the parent form appears to freeze is because EndInvoke is waiting for the child dialog to close. Brian John wrote: > Hi Guys, > > I have a tricky problem. > > I have an MDI form that builds a dynamic menu from an XML file. I set the > event handler for menu click events using > > AddressOf DoDynamicMenu > > where DoDynamicMenu opens an MDI child dialog that is held in a seperate dll > using reflection. > > I have this line of code in DoDynamicMenu: > > mInitHandler = AddressOf mAppletForm.Init > mInitHandler.BeginInvoke(mCallbackHandler, Nothing) > > (this is a call to a Init method in the MDI child forms class. this class > inherits from mAppletForm and it's Init method overrides the base class's > Init method) > > I have the async stuff set up so that a callback is called when the async > call to Init is finished. > > In this callback method I make this call > > mInitHandler.EndInvoke(ar) > > so that the async op should complete with no problems. > > However my MDI parent form (and the child dialog I am trying to load) is > freezing - like it's trying to process a message or it's waiting for a method > call to complete. > > Has anyone tried something like this before or seen a problem like this? > > Cheers, > John |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

