Results 1 to 10 of 10

Thread: Pause

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 1999
    Posts
    207

    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

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    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.

  3. #3
    Lively Member mindloop's Avatar
    Join Date
    Mar 2004
    Posts
    64

    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
    ehmm...

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Quote 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 .

  5. #5
    Lively Member mindloop's Avatar
    Join Date
    Mar 2004
    Posts
    64

    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.
    ehmm...

  6. #6
    Lively Member mindloop's Avatar
    Join Date
    Mar 2004
    Posts
    64

    Re: Pause

    curiously Thread.Sleep(x); does the trick...
    ehmm...

  7. #7
    Lively Member mindloop's Avatar
    Join Date
    Mar 2004
    Posts
    64

    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 ?
    ehmm...

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Quote 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 .

  9. #9
    Lively Member mindloop's Avatar
    Join Date
    Mar 2004
    Posts
    64

    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
    ehmm...

  10. #10
    Fanatic Member
    Join Date
    May 2001
    Posts
    837

    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
  •  



Click Here to Expand Forum to Full Width