Created
March 9, 2017 07:17
-
-
Save KennethanCeyer/7aa42474cfbe58d6acda2d85d0b2f17f to your computer and use it in GitHub Desktop.
Async Task Without await
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
publicJsonResult Wait(int time) | |
{ | |
Task.Factory.StartNew(() => { | |
Thread.Sleep(time); | |
Debug.WriteLine("Done " + time); | |
}); | |
return APPActor.GetJson(new | |
{ | |
msg = time | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
public async Task<JsonResult> Wait(int time) | |
{ | |
// This will go to doen't working. | |
Task.Factory.StartNew(() => { | |
Thread.Sleep(time); | |
Debug.WriteLine("Done " + time); | |
}).ConfigureAwait(false); | |
return await APPActor.GetJsonAsync(new | |
{ | |
msg = time | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment