Question How can I stop running application using button in Windows Form during runnig

andree22

New member
Joined
Nov 26, 2013
Messages
3
Programming Experience
5-10
Hi there
I've got a big problem. I've looked for the solution for almost a week and I didn't find an answer.
I have an application which does some things, but during runnig it, in some moment I would like to stop this with click a button. I've already made a boolean variable, to do this programaticaly, but during the application is runnig I can't click anything, because the button doesn't ract.
Does somebody know how to change Windows Form options to let me click a button during the application is running?
 
I can't click anything, because the button doesn't ract.
That is because you are doing processing in the UI thread, which you should not do. Processing should be done on a secondary thread to allow the application to be responsive. There is a BackgroundWorker component that you can add to your form from Toolbox, this component makes multi-threading in Windows Forms environment very easy. I recommend you read up and start using that. It also includes functionality to help cancel work in progress.
 
You should certainly start by reading the MSDN documentation for the BackgroundWorker class and related types and members but, after that, you might like to check this out:

Using the BackgroundWorker Component
 
Back
Top