Application can't be interrupted when running in a loop

R

Rvo

I have written an application that manipulates files, while doing so the
program is running in a loop and any actions on the GUI will not get any
response. When I try to stop the processing of the files trough the GUI by
clicking on a button this will not be done.

The action connected to the stop-button is to set a boolean to "true"
in the loop which processes the files I check contiuously for the boolean
becomming true and if so exit the loop.
But this condition is never set to true.

Is there a way to write code that still accepts user input while running in
a loop?

Kind regards,

Romain Voes
 
H

Herfried K. Wagner [MVP]

* "Rvo said:
I have written an application that manipulates files, while doing so the
program is running in a loop and any actions on the GUI will not get any
response. When I try to stop the processing of the files trough the GUI by
clicking on a button this will not be done.

The action connected to the stop-button is to set a boolean to "true"
in the loop which processes the files I check contiuously for the boolean
becomming true and if so exit the loop.
But this condition is never set to true.

I would use multithreading to do that. You can find a sample here:

<URL:http://dotnet.mvps.org/dotnet/samples/filesystem/downloads/FileSystemEnumerator.zip>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top