The MSDN documentation appears to state that async
and await
are suitable for IO-bound tasks whereas Task.Run
should be used for CPU-b
There are several things to consider:
Task.Run()
is probably a good idea. Though the users of your code can do that themselves, if they want.Task.Run()
instead of running the code directly, but it shouldn't be significant if the operation actually takes some time. (Also, there is some overhead in returning to the synchronization context, which is one more reason why you should use ConfigureAwait(false)
for most await
s in your library code.)Weighting that, I think using await Task.Run()
is the right choice here. It does have some overhead, but also some advantages, which can be significant.