C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2720
Number of posts: 5746

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
C# timer Posted by George Steeves on 3 Feb 2006 at 4:31 PM
Is there an easy way to do in C# what I would do in C++ with
delay(1000);
Report
Re: C# timer Posted by weicco on 4 Feb 2006 at 12:04 AM
: 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.
Report
Re: C# timer Posted by George Steeves on 4 Feb 2006 at 4:06 AM
: : 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.
:



Report
Re: C# timer Posted by George Steeves on 4 Feb 2006 at 4:31 AM
: : : 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.

Report
Re: C# timer Posted by weicco on 5 Feb 2006 at 1:05 AM
: : : : 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 ...
Report
Re: C# timer Posted by tsagld on 13 Feb 2006 at 8:06 AM
: : : : : 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:
System.Threading.Thread.Sleep(1000);


Greets,
Eric Goldstein
www.gvh-maatwerk.nl

Report
Re: C# timer Posted by weicco on 14 Feb 2006 at 12:26 AM

: No, the Sleep method is static:
:
: System.Threading.Thread.Sleep(1000);
: 

:
: 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 :)



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.