locked
Inserting a 1 second pause in a VB2010 express program

    Question

  • Is there a command or couple of code lines that will pause the running program for one or two seconds?

    I have a program that checks the system time every 250milliseconds and I need to skip checking it three times the first time it comes back with ":00" seconds from the system clock.

    Or another option would be to reset the timer to 1000 and then back to 250...

    Any suggestions would be helpful.

    Thank you in advance,

    Richard.

    Monday, November 22, 2010 9:10 AM

Answers

  • Thanks for the suggestions, but it came to me just before I booted up for the night tonight. I already put it in and it works.

    The answer was one line of code... an "If Then Else" choice:

    If Now.Second=0 Then Timer.Interval=1000 Else Timer.Interval=250
    

    I put it as the very first executable line in that thread.

     

    Again thanks for the suggestions.

    Richard

    • Marked as answer by RichardInTN Tuesday, November 23, 2010 12:57 AM
    Tuesday, November 23, 2010 12:57 AM

All replies

  • Hi,

    Try perhaps http://msdn.microsoft.com/en-us/library/d00bd51t.aspx. Or you could also have a counter variable that will allow to ignore the next "counter" events by returning immediately.

    Sometimes it's best to explain the overall goal as it could raise better suggestion or alternate approaches...


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".
    Monday, November 22, 2010 2:58 PM
  • Have you thought of using System.Threading.Thread.Sleep?
    Para el correcto funcionamiento, y que otros usuarios se puedan beneficiar de la solucion de esta pregunta por favor marca las respuestas que te hayan ayudado como "Respuesta".
    Si la respuesta te ha sido util Votala.
    Mi Blog: Jtorrecilla
    Enlace a Faq de Winforms en Ingles Muy bueno
    Monday, November 22, 2010 3:01 PM
  • Thanks for the suggestions, but it came to me just before I booted up for the night tonight. I already put it in and it works.

    The answer was one line of code... an "If Then Else" choice:

    If Now.Second=0 Then Timer.Interval=1000 Else Timer.Interval=250
    

    I put it as the very first executable line in that thread.

     

    Again thanks for the suggestions.

    Richard

    • Marked as answer by RichardInTN Tuesday, November 23, 2010 12:57 AM
    Tuesday, November 23, 2010 12:57 AM