PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms Re: using async in windows forms

Reply

Re: using async in windows forms

 
Thread Tools Rate Thread
Old 10-01-2007, 04:07 PM   #1
Brian Gideon
Guest
 
Posts: n/a
Default Re: using async in windows forms


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


  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off