I am using the 2017a runtime and trying to figure out how to pass a cancellation request.
When using the COM interface, I can put a pause in a function which seems to yield to pending requests and allows me to set a cancellation request flag. I do this using a global variable. Then, during those long running functions, it checks for that flag in different places.
When I try to run the same code using the MATLAB Runtime, the call to set the cancellation request flag doesn't make it through at the pause.
The code for checking for the flag looks like this:
function requested=cancel_requested()
global cancel_requested_flag;
pause(0.01);
requested = cancel_requested_flag;
cancel_requested_flag = false;
end
I call this function in various places to check for that flag. The code for setting the flag is below.
function request_cancel()
global cancel_requested_flag;
cancel_requested = true;
end
My cancel button just calls this request_cancel function. Again, this all works when using the COM interface. Any ideas how I can get this to work with the MATLAB Runtime? With the Runtime, it waits until the original function completes to call request_cancel. Pause doesn't seem to yield control the same way it does with the COM interface.