After looking around on both Async/Await and Threading, I\'m still unsure of the right way to apply it to my situation. No matter the variation that I try my UI still hangs
Instead of trying to use a bool
for this, you should consider using the managed cancellation framework built into the framework.
Basically, you'd build a CancellationTokenSource
, and pass a CancellationToken
to your method which could be used to handle cancellation.
Finally, your current method will never get off the UI thread. You'd need to use Task.Run
or similar to move the method to the ThreadPool if you don't want to block the UI.