PDA

Click to See Complete Forum and Search --> : Pause


Jeremy Martin
Dec 28th, 2002, 07:37 PM
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

hellswraith
Dec 28th, 2002, 08:44 PM
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.

mindloop
Mar 28th, 2005, 01:29 PM
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

Pirate
Mar 28th, 2005, 03:44 PM
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 .

mindloop
Mar 28th, 2005, 03:48 PM
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.

mindloop
Mar 28th, 2005, 03:49 PM
curiously Thread.Sleep(x); does the trick...

mindloop
Mar 28th, 2005, 03:51 PM
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 ?

Pirate
Mar 28th, 2005, 03:57 PM
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 .

mindloop
Mar 28th, 2005, 04:05 PM
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

DNA7433
Apr 1st, 2005, 09:09 AM
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.