Passing message between forms

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

I've got a Main Form that takes a list of files. You click the "Process
Button", it then opens a new "Batch" form which processes the images files
one at a time. Unfortunatley the process takes a bit of time but my code
keeps running, not waiting for the batch to get done. How can I have the
"Main" form wait until the Batch form is finished with it's job, before the
"Main" form sends another job to the "Batch" form?

Sorry for being so wordy.. Still trying to get my mind around this problem.

For Example:

processBatchList()
{
for (batchLoop = 0; batchLoop <= numberOfRowsInDataGrid; ++batchLoop)
{
try
{
// Use Multidimensional Array
string imageFilePath = processImageQue[batchLoop, 0];
string imageFileSaveLocation = processImageQue[batchLoop, 1];
BatchForm processImage = new BatchForm(imageFilePath,
imageFileSaveLocation);
processImage.Show();
}
catch
{
// Handle the error
}
}
}


When the try happens how can I make it wait for a message back from the
processImage instance of BatchForm? And how would I send back a message
from BatchForm?

thanks,
jim
 
How can I have the
"Main" form wait until the Batch form is finished with it's job, before the
"Main" form sends another job to the "Batch" form?

It sounds like your "Batch" form isn't really a form but a process. If
that's the case look at this sample:

Multithreaded Windows Forms Control Sample
ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpcondevelopingmultithreadedwindows
formscontrol.htm
 
Maybe instead of .Show() use the .ShowDialog() method to have a modal
form displayed ?

And so the loop is beeing waiting for it to self close before
continuing...


Cybertof.
 
Back
Top