Passing message between forms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim

    Passing message between forms

    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:

    processBatchLis t()
    {
    for (batchLoop = 0; batchLoop <= numberOfRowsInD ataGrid; ++batchLoop)
    {
    try
    {
    // Use Multidimensiona l Array
    string imageFilePath = processImageQue[batchLoop, 0];
    string imageFileSaveLo cation = processImageQue[batchLoop, 1];
    BatchForm processImage = new BatchForm(image FilePath,
    imageFileSaveLo cation);
    processImage.Sh ow();
    }
    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


  • Empire City

    #2
    Re: Passing message between forms

    > How can I have the[color=blue]
    > "Main" form wait until the Batch form is finished with it's job, before[/color]
    the[color=blue]
    > "Main" form sends another job to the "Batch" form?[/color]

    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/cpcondeveloping multithreadedwi ndows
    formscontrol.ht m



    Comment

    • Cybertof

      #3
      Re: Passing message between forms

      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.


      In article <#Reomy9pDHA.39 2@TK2MSFTNGP11. phx.gbl>,
      tranzparency@ya hoo.com says...[color=blue]
      > 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.
      >[/color]

      Comment

      Working...