HI,
During the development of my app, I was using Thread.Sleep to give our external devices some time to adjust to settings before making queries, as they are quite old and slow.
I now want to replace these with something a bit more stylish and correct.
Does anyone have a simple way to “wait” for a device rather than sleep, bearing in mind the device does not let us know when it is ready, so a wait is about as good as we can do !??
Regards, George.
It may be a better fit to go down the route of using a timer to periodically wake up and see if the device is ready.
You have at least two options here
System.Timers.TimerorSystem.Threading.Timer.However, this would probably mean you’d have to get more involved in multithreading in order that the timer can notify the rest of your program to continue when the device is ready (e.g. using a
WaitHandleor some sort, such as anAutoResetEvent).There isn’t anything intrinsically wrong with using
Thread.Sleepto block a single synchronous thread IMHO.