locked
How do I wait for serial input in the background? RRS feed

  • Question

  • I am currently creating an application in C# which involves serial input. One thing I need to do is make the application wait until it receives a certain input before continuing. Previously, I was using a while loop to see if there was nothing in the buffer and stop the thread for 1000 cycles if the buffer was clear. If it wasn't, I would use the input to continue running the application. However, while the program is waiting for input, it freezes up completely because the wait code is running in the main thread. Is there any way I can cause my application to wait for serial input before continuing, but do it in the background so that the whole program won't freeze up? Thanks in advance!
    Friday, April 24, 2009 2:03 AM

Answers

  • Hi,

    If you want to get the data from serial port when it receives data, you can use datareceived event from serail port class.
    It fires when serial port receives any data.
    • Marked as answer by ahawesome Friday, April 24, 2009 9:13 PM
    Friday, April 24, 2009 2:51 AM

All replies

  • Hi,

    If you want to get the data from serial port when it receives data, you can use datareceived event from serail port class.
    It fires when serial port receives any data.
    • Marked as answer by ahawesome Friday, April 24, 2009 9:13 PM
    Friday, April 24, 2009 2:51 AM
  • Thanks. I didn't realize that was there. I'll figure out a way to use it.
    Friday, April 24, 2009 9:13 PM