Problem with simple TCP Application

Mr. Voodoo

New member
Joined
Sep 11, 2008
Messages
3
Programming Experience
1-3
I tried making a simple client-server TCP application, in which the server

sends a message to the client, say "LOAD_FORM", and the client responds by

loading a form.

So, class "CLASS_SERVER" has a method "RUN" which is called on a separate

thread by some other form.


VB.NET:
Sub Run()

	Dim MSG_FROM_SERVER As String
	While (True)
	
		MSG_FROM_SERVER = reader.ReadLine()		
		
		if MSG_FROM_SERVER = .... Then
			...
		ElseIf MSG_FROM_SERVER = LOAD_FORM Then
			Form10.Show()
	End While
End Sub


With this code, Form10 is not even completely loaded, and the program seems

to have gone into some infinite loop. I am guessing, that the program

resumes with the infinite loop, just after calling Form10, and that is why

the form isn't completely loaded. Am I right?

Also, when I replace

VB.NET:
Form10.Show()

with

VB.NET:
Dim temp As System.Threading.Thread
temp = New Thread(New ThreadStart(SOME_OTHER_FORM.ShowForm10))
temp.Start()

.. The form loads for an instant, and then vanishes from the screen. Why

does that happen?

And ofcourse, Form10.ShowDialog() works, but then it stalls the loop, which

is not what I need.

How can I fix this problem so that Form10 is loaded and the loop continues

normally ; responding to other "MSG_FROM_SERVER"s... ?
 
Back
Top