D
dm_dal
Gentlemen,
My question is simple. When my WindowsForm calls an Async Delegate which
has a registered CallBack, is the CallBack always executed on the UI Thread?
Or, do I need to test to see if it is?
In my application (MDI), I have a main form that launches another form.
When that child form loads it executes an Async Delegate who's target is a
method on a static class (Controller). The CallBack is registered on the
child form. In the callback, I check the IAsyncResult and if it was
successful, I want to trigger an event on the MDIParent to launch another
WindowsForm. Problem is, the second form is never launched. I can step
through the execution in the debugger, and can see the callback getting
executed, it runs to the event call and then everything stops. UI doesn't
freeze or anything like that, it just doesnt launch the second form. I have
noticed that sometime the second form does launch, but it appears as though
the thread it's on is blocked. It appears briefly, freezes, and then
disappears.
It definately appears as though the callback is executing on the worker
thread and that the events are being fired in that worker thread. That
would explain the blocking and possibly the reason for the form to close
(apparently after the thread is finished processing).
If it is on another thread, then would I use the ISynchronizeInvoke
interface to test whether the callback is on the UI thread? How would I
reference the form where the callback is registered?
David Young
My question is simple. When my WindowsForm calls an Async Delegate which
has a registered CallBack, is the CallBack always executed on the UI Thread?
Or, do I need to test to see if it is?
In my application (MDI), I have a main form that launches another form.
When that child form loads it executes an Async Delegate who's target is a
method on a static class (Controller). The CallBack is registered on the
child form. In the callback, I check the IAsyncResult and if it was
successful, I want to trigger an event on the MDIParent to launch another
WindowsForm. Problem is, the second form is never launched. I can step
through the execution in the debugger, and can see the callback getting
executed, it runs to the event call and then everything stops. UI doesn't
freeze or anything like that, it just doesnt launch the second form. I have
noticed that sometime the second form does launch, but it appears as though
the thread it's on is blocked. It appears briefly, freezes, and then
disappears.
It definately appears as though the callback is executing on the worker
thread and that the events are being fired in that worker thread. That
would explain the blocking and possibly the reason for the form to close
(apparently after the thread is finished processing).
If it is on another thread, then would I use the ISynchronizeInvoke
interface to test whether the callback is on the UI thread? How would I
reference the form where the callback is registered?
David Young