|
-
Dec 28th, 2002, 08:37 PM
#1
Thread Starter
Addicted Member
Pause
Hello,
I have come across a weared situation. I need to come up with a way to have a function pause in a particular place for x numbers of seconds without tying up the processor. I tried using a loop and just add to a variable but that will keep the processor bussy.
Any help would be appreciated.
Jeremy
-
Dec 28th, 2002, 09:44 PM
#2
PowerPoster
Something like this:
Threading.Thread.CurrentThread.Sleep(x)
Like if you wanted it to sleep for 10 seconds, you would put 10000 for x. 1000 equals one second.
-
Mar 28th, 2005, 02:29 PM
#3
Lively Member
Re: Pause
hmm i keep seeing this solution for pause, and i know it works in vb.net, i used it alot, yet in c# i keep ending up with this compiler error:
C:\C#\prjQuickSort\MainForm.cs(270): Static member 'System.Threading.Thread.Sleep(int)' cannot be accessed with an instance reference; qualify it with a type name instead
-
Mar 28th, 2005, 04:44 PM
#4
Sleep mode
 Originally Posted by mindloop
hmm i keep seeing this solution for pause, and i know it works in vb.net, i used it alot, yet in c# i keep ending up with this compiler error:
As the compiler says : qualify Sleep method with the fullname(you should do this with any static member) . Maybe if you show some code , we could help .
-
Mar 28th, 2005, 04:48 PM
#5
Lively Member
Re: Pause
there's no need, just try using Threading.Thread.CurrentThread.Sleep(x);
in c#, i'm pretty sure you will get the same error.
please correct me if i'm wrong.
-
Mar 28th, 2005, 04:49 PM
#6
Lively Member
Re: Pause
curiously Thread.Sleep(x); does the trick...
-
Mar 28th, 2005, 04:51 PM
#7
Lively Member
Re: Pause
You just made me curious, what do you mean with
qualify Sleep method with the fullname(you should do this with any static member)
?
how do i do that ?
-
Mar 28th, 2005, 04:57 PM
#8
Sleep mode
 Originally Posted by mindloop
You just made me curious, what do you mean with ?
how do i do that ?
It's like this :
System.Threading.Thread.StaticMethodxxxx (this is fully-qualified name) .
You don't have to create an instance obj though .
I used Thread.Sleep(x); like (7 times) in one of my apps , it works with no errors at all .
-
Mar 28th, 2005, 05:05 PM
#9
Lively Member
Re: Pause
i know , just wanted to point out, after a massive search on the forum that the sollution Threading.Thread.CurrentThread.Sleep(x) was always suggested and it's broken.
bout your last post i must dig into that a bit. static modifier is pretty interesting... thx
-
Apr 1st, 2005, 10:09 AM
#10
Fanatic Member
Re: Pause
VB.NET lets you access shared methods through instances of objects or the class name. C# only allows you to use the class name. Go figure.
The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|