ShowDialog, Events and Control Invoke

D

Duncan Mole

Hi,

I have 2 forms that subscribe to the same event published by the same
instance of an object. In each case the event handler invokes the
invalidation of a member panel using a reference to initial form in the
application - ie definatley the GUI thread.

The problem arises when I launch form B from form A with ShowDialog(). Now
when the event is fired my invoke is called on the first form to subscribe -
A, this call never completes and B's handler is not called by the event
delegate. One can assume that a control cannot be invoked when it is waiting
for ShowDialog to return.

Whilst I think I understand the problem I am suprised at the conclusion I
must draw. In order to remain vsually responsive to a particular event forms
may not be shown modally.

Has anyone else come up against this problem? There must be a work around
there somewhere. Is this what BeginInvoke in the full framework is for?
 
D

Duncan Mole

I think have found out that having any open modal dialogs will effectively
prevent the GUI thread from performing invokes. In effect the invokes are
queued and only run once the modal is closed.
 
D

Dave Hall

Take a look at the thread entitled 'UI Thread V Worker thread' in
microsoft.public.dotnet.framework.windowsforms.controls newsgroup. Last
night, I posted a somewhat lengthy response there which seems to be related
to your situation. It's not necessarily an answer, but it offers some
possible solutions. Hopefully, some of the OpenNetCF and MVP gurus can
comment on the solutions I propose there.

Dave
 
A

Anthony Wong [MSFT]

Hey Duncan, do you mind attaching a piece of code reproducing the issue so
that I can take a look at it?

Thanks,
Anthony

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top