Your async
method has no await
in it. You should see a compiler warning you telling you exact that. Because there is no await
, there is no asynchrony; you have an entirely synchronous method that just happens to wrap its result in a Task
.
There are two general options here.
Change the actual IO that you are doing from synchronous IO to asynchronous IO. The web service code can be modified to generate task returning methods, rather than methods that block while the IO is taking place. You can then
await
those IO methods, rather than having yourasync
method calling blocking IO.Just make your entire application synchronous. Get rid of
async
onnCallAsync
(and remove theAsync
suffix). Then just call the method usingTask.Run
to perform the operation in another thread. This option isn't nearly as preferable, as you're having a thread pool thread sitting around doing nothing but waiting on an asynchronous operation, but if it's not possible or feasible to actually use entirely asynchronous IO, sometimes you have to resort to this.