My app contains a procedure which could be long-running. I would like to give users the opportunity to stop it.
The procedure is:
(it does not access the file system or the Internet)
And within it, once certain variables are initialized, it calls doIt();
I tried this:
async void longRunningProcedure()
and within this procedure, I have tried:
await Task.Run(() => doIt());
and have tried:
await Task.Run(async () => await doIt());
But when the code reaches this point I get this error:
The selected debug engine does not support any code executing on the current thread (e.g. only native runtime code is executing).
The long-running code doesn't even run at all.
What to do?