ShowDialog() problem

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi, I already asked such question and also got some comments but when
I added details - no more responds.

Ok, here the story:
Main form starts the additional thread.

The thread contain such code:

Dim frm_Zip As New frmZIP
frm_Zip.ShowDialog()

as a result frmZip instead of be as modal dialog, it is modeless - I
can switch between forms.

Does it because of different threads ?
If yes, how can I fix it?

Thanks
 
Tell it what form is it's owner, and it'll be modal related to that form.

Dim frm_Zip As New frmZIP
frm_Zip.ShowDialog(Me)
 
Does it because of different threads ?
If yes, how can I fix it?

Try specifying the owner in the call to ShowDialog:

frm_Zip.ShowDialog(Me)

See if that helps
 
Chris Dunaway said:
Try specifying the owner in the call to ShowDialog:

frm_Zip.ShowDialog(Me)

See if that helps

Yes, this helped me, but only small improvement: because 'Me' is the
instance of class which represend the current instance I need to send
not me, but real instance of the Main form, like it:
frm_Zip.ShowDialog(frm_MainForm)

Thanks for all your responses
 
* (e-mail address removed) (Mike) scripsit:
Hi, I already asked such question and also got some comments but when
I added details - no more responds.

Ok, here the story:
Main form starts the additional thread.

Remember that .NET Windows Forms controls'/forms' instance members are
not thread safe. Instead of instantiating the form in the new thread,
call a function in the main thread (though 'Control.Invoke') which
instantiates and shows the form.
 
Back
Top