|
-
Dec 6th, 2008, 09:03 AM
#1
Thread Starter
Frenzied Member
[2005] How to interrupt an process
how to stop an running function or subject.
I have written an subject which when executed takes some time to finish. i have also placed an cancel button to cancel the executed of the subject.
So i wanted to know how to cancel the execution of the subject in the middle and release the resources used.
-
Dec 6th, 2008, 09:25 AM
#2
Re: [2005] How to interrupt an process
Your use of the term "subject" is incorrect. Presumably you are talking about a Sub (Sub Procedure). The name "Sub" is short for subroutine, not subject. A Sub is a method that doesn't return a value, while a Function is a method that does return a value.
While it's not impossible to do what you're asking for in a single thread, it's really not a good idea to do so. I would suggest executing your method in a background thread. If you use a BackgroundWorker to do so then the cancellation mechanism is built in. Follow the BackgroundWorker link in my signature for an example. The example you need is in post #19.
Just note that you can only cancel the background operation at certain points. You cannot stop it during a synchronous method call. You can only cancel the operation at places where you can specifically place code to do so.
-
Dec 6th, 2008, 09:32 AM
#3
Thread Starter
Frenzied Member
Re: [2005] How to interrupt an process
Ok! I will give it a try
Thanks!
and
Subroutine not subject
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|