C# Wait function.
Friday, October 28, 2011
[BS] C# Wait function.
Hey Guys, You may notice that I’m posting more tutorials. I’ve decided to expand out my responsibilities a little bit. Most of you this wont apply to but possibly it will help a few on the internet. I am developing a new software in c# and I’m learning a lot. One thing I learned recently is that Thread.Sleep() pauses the javascript loading of my browser within my program. Well I need to pause the program logic, but not pause any internal processing. For this reason I’ve written a function to help pause the program logic. It could be considered a wait() instead of a sleep(). Hope it helps: public static int f_sleep(int time) { System.DateTime now = System.DateTime.Now; System.TimeSpan duration = new System.TimeSpan(0, 0, 0, time); System.DateTime then = now.Add(duration); while (then>DateTime.Now) { //MessageBox.Show("NewTime:" + then + "Now:" + DateTime.Now); Application.DoEvents(); Thread.Sleep(10); } return 1; } Similar Posts: Autoblog Blueprint 2.0 Very Big Recommendation 9.4.2.1 Autoblogging Scheduled Posts every X seconds and hours. 9.1.1.1 Adding The Date to the Post Title or Post body using a shortcode Autoblog: Drop Posting Module BlogSense 3.8 Release More News Inside
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment