I need to wait 2 seconds for a serial port to respond, then return a value. What is the best way to accomplish that without locking the UI thread?
I have a class called Test and I create an instance of it in the main form of my program. I have several event handlers to pass data back to the main form and update the UI. My Test class has a method called runTest that has two loops. The first loop calls conTest. When that is done the second runs and calls hiPotTest. In conTest and HiPotTest I send the command via serial port to start the test. What I want to do is wait 2 seconds (for example) and get the result and return that from conTest and hiPotTest. My first thought was thread.sleep but then I decided that that would probably lock the UI during that time. Is that correct and if so what's the best way to avoid this.
I can't test this part of my program until monday at work. So right now I just have a guess as to what will happen.