ADO DOT NET Posted March 27, 2007 Posted March 27, 2007 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:) Quote
Administrators PlausiblyDamp Posted March 27, 2007 Administrators Posted March 27, 2007 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? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
ADO DOT NET Posted March 27, 2007 Author Posted March 27, 2007 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 Quote
Leaders snarfblam Posted March 28, 2007 Leaders Posted March 28, 2007 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. Quote [sIGPIC]e[/sIGPIC]
OMID SOFT Posted April 5, 2007 Posted April 5, 2007 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() Quote Don't ask what your country can do for you, ask what you can do for your country...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.