Multi Threading.......

callraheel

Well-known member
Joined
Dec 12, 2004
Messages
65
Location
London,UK
Programming Experience
1-3
Hello
I wanna make a thread which could run in my application independent of main application and stay there until i exit my main application......
Now what i want to make in that thread?
I want that thread to check the state of MySQL Server being installed on that machine or on network and when the sever is not connected or running then it should display a tool tip about it....

I just need help on how to create that thread...I mean which cant hang the main application and keep on running until my application closes.

Waiting for reply....
Regards
 
VB.NET:
Dim incthread As New Thread(AddressOf incomingthread)
incthread.Start()
and then all you need to do is make a sub called incomingthread in this example
 
Could you put all you code for that thread inside an infinite loop?

eg

VB.NET:
Sub MyThread()
   While 1=1
	   ... code here 
	   ... that will execute until terminated externally
   end while
end sub

It might be a bit of a fudge, but it should work, as long as other threads are not relying on data being returned from it.
If they are, then the only thing I can think of doing, is re-statring the thread once the return data has been received

Richard
 
Hello,

i got an error,

"Cross-thread operation not valid : control txtinput accessed from a thread other than the thread it was created on"

how can i fix that error?

Thanks.
 
You should'nt be trying to access controls other that the thread that the control was created on, trying this can cause unpredictable behaviour if you 'force it' to work. VB.net has a way of merging the incoming thread back with main UI thread. Check out the 'Invoke Required' Method.
 
How would you do thread safe calls to a combo box? Or numeric Up Down

The documentation for a text box is highly explained but for a combo box or a numeric up down... The numeric up down of course does not send a text value it sends a decimal value how would you call that in a thread safe way. Is their anything on msdn about thread safe calls to a combo box? Probably Ill look right now but the general thread safe practice thread uses text boxes.
 
It doesn't matter what control you need to access, the procedure is always the same; check the controls InvokeRequired, if needed you use its Invoke method to call a delegate pointing to method you want done on the control thread.
 
Back
Top