Updating a mainform from a thread generated by a modal dialog!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a main form which can have controls updated from separate threads, using Control.Invoke(). In actual fact, these are update methods called by events from a remoted singleton. Now, I have a modal dialog called from the main form, which changes settings in the remoted singleton. The singleton then throws update events caused by the settings changes, which the main form handles. (The modal dialog has not been dismissed) The problem is, the Control.Invoke method in the main form appears to be freezing, probably due the fact that the modal dialog is still visible, which is waiting for the method calls to return. There appears to be a deadlock situation!

Anyone experienced this before and got any ideas on getting round it?

Thanks

Jon
 
Hi Jon,

IMHO the problem of freezing is not in the modal dialog. Control.Invoke uses
message pump in order to execute methdos in the main UI thread. Even though,
the UI thread looks stopped in ShowDialog the a message pump is working so
there should be any problems in that case.
Keep in mind that executing a method thru Control.Invoke is high priority
operation, which in turm means that if you call Control.Invoke very
intensively the UI thread will execute that method and won't update the UI
and it will look like freezed.

--

Stoitcho Goutsev (100) [C# MVP]


Jon said:
Hi

I have a main form which can have controls updated from separate threads,
using Control.Invoke(). In actual fact, these are update methods called by
events from a remoted singleton. Now, I have a modal dialog called from the
main form, which changes settings in the remoted singleton. The singleton
then throws update events caused by the settings changes, which the main
form handles. (The modal dialog has not been dismissed) The problem is, the
Control.Invoke method in the main form appears to be freezing, probably due
the fact that the modal dialog is still visible, which is waiting for the
method calls to return. There appears to be a deadlock situation!
 
Back
Top