R
RedLars
Hi,
In the below example, what is the preferred approach to ending the
thread execution from the Dispose method? Using Thread.Abort would be
one appraoch. Changing while(true) to while(SomeVariable) and then
control SomeVariable from dispose(..) would be another way. Maybe
using some sort of synchronize mechanism also would work? What do you
recommend?
Thread pollDeviceThread = new Thread(new ThreadStart(PollDevice));
private void PollDevice()
{
while(true)
{
// Do work
Thread.Sleep(POLL_DEVICE_UPDATE_TIME);
}
}
protected virtual void Dispose(bool disposingManagedResource)
{
}
In the below example, what is the preferred approach to ending the
thread execution from the Dispose method? Using Thread.Abort would be
one appraoch. Changing while(true) to while(SomeVariable) and then
control SomeVariable from dispose(..) would be another way. Maybe
using some sort of synchronize mechanism also would work? What do you
recommend?
Thread pollDeviceThread = new Thread(new ThreadStart(PollDevice));
private void PollDevice()
{
while(true)
{
// Do work
Thread.Sleep(POLL_DEVICE_UPDATE_TIME);
}
}
protected virtual void Dispose(bool disposingManagedResource)
{
}