Whit is the different between Task vs Thread?
Whit is the different between Task vs Thread
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rajkiran SwainPosted Jun 27, 2017, 8:02 AM
Manikandan MurugesanPosted Jun 26, 2017, 12:13 PM
Manikandan MurugesanPosted Jun 26, 2017, 12:11 PM
Sundaram SubramanianPosted Jun 26, 2017, 7:58 AM
Threadis a lower-level concept: if you're directly starting a thread, you know it will be a separate thread, rather than executing on the thread pool etc.Taskis more than just an abstraction of "where to run some code" though - it's really just "the promise of a result in the future". So as some different examples:Task.Delaydoesn't need any actual CPU time; it's just like setting a timer to go off in the futureWebClient.DownloadStringTaskAsyncwon't take much CPU time locally; it's representing a result which is likely to spend most of its time in network latency or remote work (at the web server)Task.Run()really is saying "I want you to execute this code separately"; the exact thread on which that code executes depends on a number of factors.