I am monitoring devices, using the example code below, and all works fine. The question is about how to handle each process at the same time. Let me explain.
When monitoring devices, we have an event that gets fired whenever a device disconnect. If for example we have to wait for each device to restart, or to reconnect to network, we use a thread.sleep() before starting the next commands. Only issue is if we have a large number of devices, each device will be done one at the time, potentially taking a long time to complete all devices. In this example, with a 10 seconds sleep, only 6 devices can be done every minutes..
How should I go to start 1 separate process for each device, and run it (almost) simultaneously? Or?
monitor.DeviceDisconnected += this.OnDeviceDisconnected;
private void OnDeviceDisconnected(object sender, DeviceDataEventArgs e)
{
......
Thread.Sleep(10000);
......
}