I have added a worker thread to a form, in my class I’ve added:
static bool msblnRunPinger = false;
const int mcintPingerSleep = 100;
Thread mthrdPinger = null;
In my class constructor:
if (mthrdPinger == null) {
msblnRunPinger = true;
mthrdPinger = new Thread(new ThreatStart(pingSites));
mthrdPinger.Start();
}
When the form is closing:
msblnRunPinger = false;
The thread function:
private static void pingSites() {
while(msblnRunPinger == true) {
//Problem is here...How can I access the form controls in a static function?
Thread.Sleep(mcintPingSleep);
}
}
See above, I need to access the form controls in the thread body, how can I do this?