Let's say I have a function Task UploadAsync(Stream stream)
upload some data to remote machine. Calling this function will make async keyword spread whole calling tree. Another way is to wrap it in Task.Run, kind of Fire and forgot way:
void DoUpload(Stream stream) {Task.Run(async () => await UploadAsync(stream)})}
I read from Stephen Cleary's blog says that Task.Run should only use for CPU bound operations, obviously uploading a chunk of data is not CPU bound. So here if I call await UploadAsync(stream)
inside Task.Run
seems a wrong way.
So my question is, is it a bad practice to use Task.Run to wrap and call async function ?