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

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
 
J

JCBarton

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

}
 

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