943,590 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 490
  • C# RSS
Jan 2nd, 2009
0

Help with Logic

Expand Post »
I need my program to "stop" as the timer is running and when the timer returns true i need it to continue what it was doing.

Sleep:

C# Syntax (Toggle Plain Text)
  1. void iUpdateStatus()
  2. {
  3. bComplete = true;
  4. //IDC_Status.Text = IDC_Status.Text + "\r\n" + DateTime.Now.ToString();
  5. }
  6.  
  7. bool sSleep()
  8. {
  9. System.Timers.Timer myTimer = new System.Timers.Timer();
  10. myTimer.Elapsed += new ElapsedEventHandler(DisplayTimeEvent);
  11. myTimer.Interval = 15000;
  12. myTimer.Start();
  13. if (bComplete)
  14. {
  15. bComplete = false;
  16. myTimer.Stop();
  17. return true;
  18. }
  19. return false;
  20. }
  21.  
  22. void DisplayTimeEvent(object source, ElapsedEventArgs e)
  23. {
  24. if(IDC_Status.InvokeRequired)
  25. {
  26. IDC_Status.Invoke(new MethodInvoker(iUpdateStatus));
  27. }
  28. }

example of the posting

C# Syntax (Toggle Plain Text)
  1. LoadText(Zone);
  2. PostTopic(3, "[RS.com] Zone Alarm Keygen", Post);
  3. //Sleep Here once timer has completed go to next lot
  4.  
  5. LoadText(Adobe);
  6. PostTopic(3, "[RS.com] All Adobe Keygens", Post);
  7. //Sleep Here once timer has completed go to next lot
  8.  
  9. LoadText(Alcohol);
  10. PostTopic(3, "[RS.com] Alcohol 120% v1.9", Post);
  11. //Sleep Here once timer has completed go to next lot
  12.  
  13. LoadText(CleanMyPC);
  14. PostTopic(3, "[RS.com] CleanMyPC", Post);
  15. //Sleep Here once timer has completed go to next lot
  16.  
  17. LoadText(DVDFab);
  18. PostTopic(3, "[RS.com] DVDFab 5.1 Final", Post);
  19. //Sleep Here once timer has completed go to next lot
Similar Threads
Reputation Points: -14
Solved Threads: 1
Junior Poster in Training
FTProtocol is offline Offline
99 posts
since May 2008
Jan 2nd, 2009
0

Re: Help with Logic

Simply put your current thread in sleep mode. Fairly easy to do with 1 line of code.

C# Syntax (Toggle Plain Text)
  1. System.Threading.Thread.Sleep(int milliseconds);
Reputation Points: 31
Solved Threads: 7
Light Poster
iDeveloper is offline Offline
49 posts
since Jul 2008
Jan 3rd, 2009
0

Re: Help with Logic

Click to Expand / Collapse  Quote originally posted by iDeveloper ...
Simply put your current thread in sleep mode. Fairly easy to do with 1 line of code.

C# Syntax (Toggle Plain Text)
  1. System.Threading.Thread.Sleep(int milliseconds);
i dont want to pause the main thread.
Reputation Points: -14
Solved Threads: 1
Junior Poster in Training
FTProtocol is offline Offline
99 posts
since May 2008
Jan 3rd, 2009
0

Re: Help with Logic

Quote originally posted by FTProtocol ...
I need my program to "stop" as the timer is running
imho that is what you asked and iDeveloper gave you a correct answer.
Reputation Points: 2023
Solved Threads: 644
Senior Poster
ddanbe is offline Offline
3,735 posts
since Oct 2008
Jan 3rd, 2009
0

Re: Help with Logic

If you have something that needs to pause and continue you shouldnt be using the mainthread for it. Thats what threads were invented for.
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Reading from pdf
Next Thread in C# Forum Timeline: Sleeping without pausing the main thread





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC