I'm using async/await to provide a continuation for a task that needs to be run in the UI context. However, the continuation may be pre-empted by another block of code that needs to wait for it to finish. Using Task.Wait() will return as soon as the Task finishes but will not guarantee that the async continuation has also completed. Is there any (elegant) way to force the continuations to be run before continuing excecution? (Using semaphores etc. will obviously deadlock because the pre-empting code will just block never allowing the continuation to happen, because they both run on the same thread).
Thanks.