Pause Execution of a vb.net application

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2006
Posts: 3
Reputation: Ayati is an unknown quantity at this point 
Solved Threads: 0
Ayati Ayati is offline Offline
Newbie Poster

Pause Execution of a vb.net application

 
0
  #1
Jul 19th, 2006
Hello,

is there a way I can pause and then Resume code execution by clicking a "Pause" /"Resume" button using Application.DoEvent, How? An example please.
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

Re: Pause Execution of a vb.net application

 
0
  #2
Jul 19th, 2006
Try something like this:
  1. Private Sub btnLoop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoop.Click
  2. Do While Not Done
  3. My.Application.DoEvents()
  4. Do While OverDone
  5. My.Application.DoEvents()
  6. Loop
  7. Loop
  8. Started = False
  9. Done = False
  10. OverDone = False
  11. End Sub
  12.  
  13.  
  14. Private Sub btnToggleDone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnToggleDone.Click
  15. If Started Then
  16. Done = Not Done
  17. End If
  18. End Sub
  19.  
  20. Private Sub btnToggleOverdone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnToggleOverdone.Click
  21. If Started Then
  22. If Not Done Then
  23. OverDone = Not OverDone
  24. End If
  25. End If
  26.  
  27. End Sub
The inner loop just waits untill the OverDone is toggled.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 3
Reputation: Ayati is an unknown quantity at this point 
Solved Threads: 0
Ayati Ayati is offline Offline
Newbie Poster

Re: Pause Execution of a vb.net application

 
0
  #3
Jul 20th, 2006
Hello,
thank you for your reply. I have some questions. In my code I am retriving binary files from a database and all its related information from other tables to send them to another database using webservices. My outer loop is my records from the database, what is the inner loop?
dose btnToggleDone and btnToggleOverdone my pause and resume buttons?

thanks
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

Re: Pause Execution of a vb.net application

 
0
  #4
Jul 20th, 2006
Originally Posted by Ayati
Hello,
thank you for your reply. I have some questions. In my code I am retriving binary files from a database and all its related information from other tables to send them to another database using webservices. My outer loop is my records from the database, what is the inner loop?
dose btnToggleDone and btnToggleOverdone my pause and resume buttons?

thanks
No btnToggleDone would not be used in your program as that is the outer loop (just so I could run it and check it). btnToggleOverdone is your pause and resume button. One way to handle this is have the button lable say "Pause" when it is false and "Resume" when it is true.
Private Sub btnTogglePauseContinue_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTogglePauseContinue.Click
If Started Then
If Not Done Then
OverDone = Not OverDone
End If
If OverDone = True Then
btnToggleOverdone.Text = "Resume"
Else
btnToggleOverdone.Text = "Pause"
End
End If
End Sub
Last edited by waynespangler; Jul 20th, 2006 at 6:35 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

Re: Pause Execution of a vb.net application

 
0
  #5
Jul 20th, 2006
  1. Private Sub btnTogglePauseContinue_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTogglePauseContinue.Click
  2. If Started Then
  3. If Not Done Then
  4. OverDone = Not OverDone
  5. End If
  6. If OverDone = True Then
  7. btnToggleOverdone.Text = "Continue"
  8. Else
  9. btnToggleOverdone.Text = "Pause"
  10. End
  11. End If
  12. End Sub
The last post did not have the code tags in the edit so I am posting the same code but indented (easier to read).
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 233
Reputation: Lord Soth is an unknown quantity at this point 
Solved Threads: 4
Lord Soth's Avatar
Lord Soth Lord Soth is offline Offline
Posting Whiz in Training

Re: Pause Execution of a vb.net application

 
0
  #6
Jul 27th, 2006
Hi,

You can use System.Threading.Thread.Sleep(200) in the inner loop along with Application.DoEvents() to avoid CPU overhead.

Loren Soth
Best regards,
Loren Soth

Crimson K. Software _________________________________________________________________ Crimson K. Blog
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC