Interrupt parfor from uiprogressdlg CancelRequested
Show older comments
I have a parfor which processes a large number of files, and I use a cancelable uiprogressdlg with a parallel.pool.DataQueue to update the progress percentage as the files are processed. As expected, I cannot read the status of progress.CancelRequested inside the parfor, but can read it inside of my DataQueue afterEach called function (updateProgress).
I am not very particular on how the cancel operation is executed, so I tried throwing an error when CancelRequested was true, but DataQueue catches this, and converts it to a warning.
I would also be fine with replicating an interrupt like Ctrl-C, as that seems to be able to break out of a parfor without issue, but there does not seem to be a way to send this type of interrupt programmatically.
The only other solution I have found is to delete the parallel pool, which is rather crude (but it does work).
Is there a different way to throw an error that would not be caught? Or some way to accomplish this cancel operation without killing my parallel pool (so the program could be started again without waiting for the pool to be restarted)?
Accepted Answer
More Answers (0)
Categories
Find more on Parallel for-Loops (parfor) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!