How to stop Invoked code running immediately after ShowDialog()closes

  • Thread starter Thread starter JCBarton
  • Start date Start date
J

JCBarton

Hi,

I have a form that shows a dialog using ShowDialog().

Whilst the dialog is displayed a worker thread that monitors files
changing on disk calls BeginInvoke() on the Form. This method displays
another dialog asking whether the user wants to update.

The problem lies in:

First dialog displayed.
<File modified on disk> - BeginInvoke() called on worker thread.
Click OK on the dialog.
.... Rather than the method that called ShowDialog() continuing - the
invoked method is run


What is the best approach to making sure the method that calls the
ShowDialog() completes and execution returns to the message loop
BEFORE the Invoked method from the worker thread is run?


Regards


John
 
Approach I took was to create a class that locks the files changed
dialog popping up:

using (new FilesChangedLocker())
{

using (new settingsDialog())
{

//get settings

}

//update project (previously would fire files changed dialog at
this point

}
 
Back
Top