Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Thread Affinity? 1

Status
Not open for further replies.

rdgerken

Technical User
Jul 8, 2002
108
I have a worker thread that polls for a connection and updates a label on my form (that was created from the main thread) that tells whether or not the connection is available. I've been reading that this is a big no no, but, my application works ok. Can anyone give me the 411 on this, and maybe explain how to communicate the information from the worker thread back to a control on my main thread created form? I'm dealing with the CF, so the simpler, the better.

Thanks
 
I'm assuming you have created the worker thread.

If you're only dealing with Online/Offline then what you're after is easy. If you're looking for something like Signal Strength and how it varies: all the power to you!

For Online/Offline:

Don't continuously check the connection by opening it or pinging it. Simply try to make your connection the first time. If it worked then your connection is open. As you try to make requests to the network you're connecting on you may get errors (if the network is unavailable). This is the point when you would re-check the connection, or simply tell the user that they are offline.

To have a thread that constantly checks the connection is a waste.

Hope this helps!
 
Hey JurkMonkey,

Thanks for the tip... I'm actually communicating to a SQL server, and I need to continuously monitor to see if I have a connection to the server or not as the user will be moving in and out of wifi areas. So I have a worker thread set up that checks to see if the DB is accessible every 15-20 seconds or so. If it is available, I set a label control to say that it is, otherwise I set it to say that it isn't. Very easy. Problem is, can I update this label from the worker thread? I've read that this is a no no, but the way that I have it now, it works fine. I just want to make sure it's done right.
 
I'm not sure how relevant this will be - its VB.Net and I'm don't know how much if any of it is applicable to the Compact Framework, but in general, at least your requirements were discussed here: thread796-1083662

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top