I know, that you can't set the value of CancellationPending of the BackgroundWorker class
The default is false.
If you call the CancelAsync()-method, CancellationPending is true.

I need to call this method, that my program stops measuring. Now you are back on the GUI. You can change values and again press the 'Start' button.

The following problem:

CancellationPending is still true. But I need it to be false.


Can you explain the senario you want to implement like:
1- call bgw
2-stop bgw
X- end
so we can help

1. Press start button
2. worker starts to work (measure)
3a. if you want to abort the measurement, you can press the abort button
3b. else the worker is finishing the measurement
4a. if you abort the measurement, then I call the CancelAsync()-method, so that CancellationPending is true and my worker is canceling the measurement.
5a. Now you are back on the GUI and can change values and other settings. You can press again START to measure again. BUT CancellationPending is still true, because the CancelAsync()-method was called when you pressed the abort button.

Therefore CancellationPending should be false.
I tested my program again and nothing happened. Everything works...
But in case that the problem appears again, can I do something, that CancellationPending is false everytime I press the start button?

no if the back ground worker canceled it set the CancellationPending to false automatically please post your cancelation procedures

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.