Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

   Private Sub SendButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendButton.Click
       'Thread
       Dim Threads As New Thread(New ParameterizedThreadStart(AddressOf myThread))
       Threads.Start()
   End Sub

   Private Sub myThread(ByVal o As Object)
       Dim F As New Form1
       F.ShowDialog()
   End Sub

Hi,

In my code, when I try to show a form in a safe thread as modal, I cannot, the form won't be modal, what can I do?

I need your help.

Thank you:)

Posted
It looks as though you are getting a second message pump for the dialog box - effectively the dialog is being modal on it's own windows message pump.

 

Is there a reason you need the dialog to have it's own thread?

 

That it just a sample, you think it is:

Private Sub SendButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendButton.Click
'Thread
Dim Threads As New Thread(New ParameterizedThreadStart(AddressOf myThread))
Threads.Start()
End Sub

Private Sub myThread(ByVal o As Object)
Dim F As New AnotherForm
F.ShowDialog()
End Sub

  • Leaders
Posted
In order for the form to be shown modally, it should be shown via the main thread. If the second thread needs to wait for the form to be closed, it should block until the main thread can signal that the form has been closed. As for the precise mechanics required, you would have to consult some reference, a tutorial, or someone who knows more about multithreading than I.
[sIGPIC]e[/sIGPIC]
  • 2 weeks later...
Posted

   Private Delegate Sub MyFormHandler()
   Private Sub ShowMyForm()
       If Me.InvokeRequired Then
           Dim d As New MyFormHandler(AddressOf ShowMyForm)
           Me.Invoke(d)
       Else
           Dim F As New MyFormForm
           F.ShowDialog()
       End If
   End Sub

Me.ShowMyForm()

Don't ask what your country can do for you, ask what you can do for your country...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...