|
-
Aug 17th, 2009, 05:28 PM
#1
Thread Starter
Hyperactive Member
ShowDialiog not working
I am receiving data from a socket, which is on its own thread, it handles everything, and then passes the data to a routine on the main form, which calls ShowDialog(Me) when the first byte of data arrives. THe problem is, the ShowDialog, doesnt work. Its acting like i just used Show instead of ShowDialog, i can still work the form behind it just fine, which is bad. Is there anyway i can fix this??
-
Aug 17th, 2009, 05:41 PM
#2
Re: ShowDialiog not working
Thats because the two forms are displayed on separate threads. Create a subroutine that creates and displays the form using ShowDialog, and then do some cross-thread calls to invoke this method on the main thread. If you do not know how to perform cross-thread calls, take a look at this CodeBank submission by jmcilhinney.
-
Aug 17th, 2009, 06:41 PM
#3
Thread Starter
Hyperactive Member
Re: ShowDialiog not working
Thanks Athiest, after reading and a bit of googling, i figured out the problem. I was already passing the tcp events to the main thread, so i THOUGHT.
The problem code was:
Code:
If frmMain.InvokeRequired Then
frmMain.Invoke MySub
else
frmMain.MySub
End if
Which, apparently because it was on its own thread, it was creating a new class of frmMain, which didnt require an invoke. I fixed it with the following code
Code:
Dim MainFrm As frmMain = CType(Application.OpenForms(0), frmMain)
If MainFrm.InvokeRequired Then
MainFrm.Invoke MySub
else
MainFrm.MySub
End if
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|