By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,458 Members | 1,299 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,458 IT Pros & Developers. It's quick & easy.

Cancelling process with Cancel event

P: n/a
VM
How can I cancel all running processes in my application when I click on the
Cancel button? When the Run button's clicked, it creates an instance of a
specified class and runs a method that reads each line of a file, processes
it , and writes it. With the Cancel button, I'd like to cancel this method.

Is this possible?

Thanks.
Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
TB

----- VM wrote: ----

How can I cancel all running processes in my application when I click on th
Cancel button? When the Run button's clicked, it creates an instance of
specified class and runs a method that reads each line of a file, processe
it , and writes it. With the Cancel button, I'd like to cancel this method

Is this possible

Yes, it's easy if you use a separate thread to perform the processing. For example, when the Run button is clicked you can start a new thread and that thread creates the instance of your specified class and proceeds to read the file and process it

In the meanwhile, your main thread can still respond to UI events and when the Cancel button is clicked you can either; 1) abort the worker thread you created before, or 2) set a flag that the worker thread examines that will indicate that it should abort its processing more gracefully

-- T
Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.