As Reed says, it really depends on the context. The code has to run at some point - but depending on the context, it may end up being run on a thread pool thread instead of some critical one.
Rather than using Task.Run
, I'd use TaskEx.Yield
:
public async Task Foo()
{
await TaskEx.Yield();
// Do expensive stuff
}
As far as I'm aware, that's basically a way of immediately returning to the caller, but allowing the rest of the async method to be scheduled straightaway. If you're in something like a Windows Forms UI thread, there's no point in doing this as you'll be back to the UI thread (and running expensive code there) immediately - but it would make sense if you're in a context where the current thread shouldn't be blocked, but continuations are run on another thread.