I have a method that is defined as
public async Task SomeAsyncMethod() { DoSomeStuff(); await Task.Run(() => { DoSomeSyncStuff(); DoSomeOtherSyncStuff(); }); var someDebugVariable = "someDebugValue"; }
The method itself does what it should do, and everything works fine. However ... it seems that the "external" async Task never ends.
Example: when I call it as follows
public void CallerMethod() { Task t = SomeAsyncMethod(); t.Wait(); }
t.Wait() never completes. Also: if I put a breakpoint when assigning someDebugVariable , it never hits.
I could add that DoSomeSyncStuff and DoSomeOtherSyncStuff really do what they assume, and debugging through them tells me that they both complete.
To prove my point, I changed my method as follows, and the results remained the same.
public async Task SomeAsyncMethod() { DoSomeStuff(); await Task.Run(() => { var a = 2; var b = 3; var c = a + b; }); var someDebugVariable = "someDebugValue"; }
EDIT
I tried to delete everything except await Task.Run , and did not change anything. This is still not complete.
The application is a WPF application. The thread of the calling thread is the user interface thread.
What am I missing here?
source share