Results 1 to 3 of 3

Thread: [RESOLVED] [2005] How to use the Timer or Stopwatch Class to timeout in 30 seconds

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2006
    Posts
    56

    Resolved [RESOLVED] [2005] How to use the Timer or Stopwatch Class to timeout in 30 seconds

    Hello,

    Nothing I have found on the Stopwatch Class shows how to watch for X seconds elapsed time in a piece of code. It seems to be generally used for performance measurements.

    What I'm doing is grabbing data from a serial port, which works, but it can't handle a connection that doesn't send data so I want to time out the serial port based on nothing happening for say 30 seconds.

    What I need is code that will do something like this pseudo-code:


    Do Until SerialPort.BytesToRead >= XXXX or timeOut = 1

    start stopwatch
    when 30 seconds elapses set variable timeOut = 1 'to be used in Do test
    stop stopwatch

    <other stuff here/>

    Loop


    Thanks,

    Ike
    Last edited by IkeConn; Jan 17th, 2007 at 04:22 PM. Reason: wrong class?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width