Wait - how ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • peteZ

    #1

    Wait - how ?

    How can I tell my C# program to do nothing for 5 secs ?

    ie. I want to slow down a process and introduce a deliberate delay.



    - peteZ



  • Joe Mayo

    #2
    Re: Wait - how ?

    "peteZ" <peteZ@aol.co m> wrote in message
    news:e$aI1$uhDH A.4024@TK2MSFTN GP11.phx.gbl...[color=blue]
    > How can I tell my C# program to do nothing for 5 secs ?
    >
    > ie. I want to slow down a process and introduce a deliberate delay.
    >[/color]

    Hi Petz,

    Try this:

    using System.Threadin g;

    ....

    Thread.Sleep(50 00);


    Joe
    --
    Learn C# with step-by-step tutorials and practical examples. Start your first program, explore lists and parsing, and understand how .NET runs your code.



    Comment

    • Michael Culley

      #3
      Re: Wait - how ?

      "Joe Mayo" <jmayo@ddiieess ppaammeerrssddi iee.com> wrote in message news:eQH7cLvhDH A.3104@TK2MSFTN GP11.phx.gbl...

      Won't that lock the app solid for 5 seconds? Better to use a loop with a DoEvents in it that checks for Now + 5seconds, or use a
      timer.

      --
      Michael Culley


      Comment

      • Joe Mayo

        #4
        Re: Wait - how ?

        "Michael Culley" <mculley@NOSPAM optushome.com.a u> wrote in message
        news:%238yXEewh DHA.752@TK2MSFT NGP12.phx.gbl.. .[color=blue]
        > Won't that lock the app solid for 5 seconds? Better to use a loop with a[/color]
        DoEvents in it that checks for Now + 5seconds, or use a[color=blue]
        > timer.[/color]

        Sure, if he does it on the UI thread. The question wasn't that specific.
        For long running processes, I'll consider pushing it off on a secondary
        Thread or do an asynchronous call.

        Joe
        --
        Learn C# with step-by-step tutorials and practical examples. Start your first program, explore lists and parsing, and understand how .NET runs your code.



        Comment

        • PeteZ

          #5
          Re: Wait - how ?

          Joe,

          cool - this was what I needed - thanks,

          - peteZ

          "Joe Mayo" <jmayo@ddiieess ppaammeerrssddi iee.com> wrote in message
          news:eQH7cLvhDH A.3104@TK2MSFTN GP11.phx.gbl...[color=blue]
          > "peteZ" <peteZ@aol.co m> wrote in message
          > news:e$aI1$uhDH A.4024@TK2MSFTN GP11.phx.gbl...[color=green]
          > > How can I tell my C# program to do nothing for 5 secs ?
          > >
          > > ie. I want to slow down a process and introduce a deliberate delay.
          > >[/color]
          >
          > Hi Petz,
          >
          > Try this:
          >
          > using System.Threadin g;
          >
          > ...
          >
          > Thread.Sleep(50 00);
          >
          >
          > Joe
          > --
          > http://www.csharp-station.com
          >
          >[/color]


          Comment

          Working...