Does async in 4.5 imply a new thread is spun up just by entering the
function?
Or do I have to use Task.Run within the method to make sure each function
exists on its own thread? I'm trying to see if there's any wisdom in this
practice I see in the code I'm working on.
public async Task<string> GetAStringAfterSyncProcessing(string processThis) {
return await Task.Run(async () => {
var processThis2 = processThis + ",";
var processThis3 = processThis2 + ",";
var nowImDone = processThis3 + ",";
return nowImDone;
});
}
I have a feeling that this is unintended design, since it makes it
impossible to walk through each line while debugging. So I'm wondering if
I'd be right in explaining to others that async automatically implies the
creating of a new thread so that the function is only called when await or
.GetAwaiter().GetResult() is used. Thanks
No comments:
Post a Comment