Results 1 to 8 of 8

Thread: Wait Function

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954

    Wait Function

    How do I create a function that waits (up to 2 hours)?

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Why do you need it to wait? There are a ton of ways to do this. The built in timer in the .NET framework would probably be the easyest solution. You could also throw some code into a loop and don't let it leave until it's 2 hours later, but that would be CPU intensive.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    I need to pause an application for a two hour period. I am building a command line app, so how do I implement the timer control...? Thanks

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    Anyone?

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    If it doesn't need to be doing anything in the background then just use Threading.Thread.CurrentThread.Sleep(#ofmilliseconds that equal 2 hours)

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    Ed! How's it my man? Anyway, I placed this syntax in...

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

    And got this error when I tried to compile....

    C:\_root\c#\WOL\wol\sql.cs(32): Preprocessor directives must appear as the first non-whitespace character on a line

  7. #7
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Hey there!

    I'm not sure what the whitespace business is, make sure you have it within a method call of some kind.

    Although on second glance it appears that the thread object doesn't have a sleep function in C# only in VB.NET.

    Wait I guess it does but as a shared only method try this:

    System.Threading.Thread.Sleep(1000);
    Last edited by Edneeis; Jan 26th, 2004 at 05:21 PM.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    As usual, you're the man...Worked great....Thanks

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