C# timer - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

C# timer

George SteevesGeorge Steeves Posts: 8Member
Is there an easy way to do in C# what I would do in C++ with
delay(1000);

Comments

  • weiccoweicco Posts: 950Member
    : Is there an easy way to do in C# what I would do in C++ with
    : delay(1000);
    :

    System.Threading.Thread.CurrentThread.Sleep(1000);

    But this is deprecated. You should create some waitable object and wait for it. Also this is pretty evil since your thread is suspended for a while and it can't for example process any messages.
  • George SteevesGeorge Steeves Posts: 8Member
    : : Is there an easy way to do in C# what I would do in C++ with
    : : delay(1000);
    : :
    :
    : System.Threading.Thread.CurrentThread.Sleep(1000);
    :
    : But this is deprecated. You should create some waitable object and wait for it. Also this is pretty evil since your thread is suspended for a while and it can't for example process any messages.
    :



  • George SteevesGeorge Steeves Posts: 8Member
    : : : Is there an easy way to do in C# what I would do in C++ with
    : : : delay(1000);
    : : :
    : :
    : : System.Threading.Thread.CurrentThread.Sleep(1000);
    : :
    : : But this is deprecated. You should create some waitable object and wait for it. Also this is pretty evil since your thread is suspended for a while and it can't for example process any messages.
    : :
    :
    :
    :
    :
    Now I get?

    Static member 'System.Threading.Thread.Sleep(int)'
    cannot be accessed with an instance reference;
    qualify it with a type name instead

    Tnx for the help.

  • weiccoweicco Posts: 950Member
    : : : : Is there an easy way to do in C# what I would do in C++ with
    : : : : delay(1000);
    : : : :
    : : :
    : : : System.Threading.Thread.CurrentThread.Sleep(1000);
    : : :
    : : : But this is deprecated. You should create some waitable object and wait for it. Also this is pretty evil since your thread is suspended for a while and it can't for example process any messages.
    : : :
    : :
    : :
    : :
    : :
    : Now I get?
    :
    : Static member 'System.Threading.Thread.Sleep(int)'
    : cannot be accessed with an instance reference;
    : qualify it with a type name instead
    :
    : Tnx for the help.
    :
    :

    Thread.CurrentThread.Sleep ...
  • tsagldtsagld Posts: 621Member
    : : : : : Is there an easy way to do in C# what I would do in C++ with
    : : : : : delay(1000);
    : : : : :
    : : : :
    : : : : System.Threading.Thread.CurrentThread.Sleep(1000);
    : : : :
    : : : : But this is deprecated. You should create some waitable object and wait for it. Also this is pretty evil since your thread is suspended for a while and it can't for example process any messages.
    : : : :
    : : :
    : : :
    : : :
    : : :
    : : Now I get?
    : :
    : : Static member 'System.Threading.Thread.Sleep(int)'
    : : cannot be accessed with an instance reference;
    : : qualify it with a type name instead
    : :
    : : Tnx for the help.
    : :
    : :
    :
    : Thread.CurrentThread.Sleep ...
    :
    No, the Sleep method is static:
    [code]
    System.Threading.Thread.Sleep(1000);
    [/code]

    Greets,
    Eric Goldstein
    www.gvh-maatwerk.nl

  • weiccoweicco Posts: 950Member

    : No, the Sleep method is static:
    : [code]
    : System.Threading.Thread.Sleep(1000);
    : [/code]
    :
    : Greets,
    : Eric Goldstein
    : www.gvh-maatwerk.nl
    :
    :

    OMG! I could've sworn it is non-static but you are absolutely right. Well, I've been known to make mistakes from time to time :)
Sign In or Register to comment.