How do I create a function that waits (up to 2 hours)?
Printable View
How do I create a function that waits (up to 2 hours)?
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.
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
Anyone?
If it doesn't need to be doing anything in the background then just use Threading.Thread.CurrentThread.Sleep(#ofmilliseconds that equal 2 hours)
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
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);
As usual, you're the man...Worked great....Thanks