Multithreading will have a worker thread that consumes more CPU.
Asynchronous will use the DMA mode IO operation
usingSystem;usingSystem.Collections.Generic;usingSystem.IO;usingSystem.Linq;usingSystem.Net;usingSystem.Text;usingSystem.Threading;usingSystem.Threading.Tasks;namespaceconsoleapplication1{classProgram {Static voidMain (string[] args) { varp =NewProgram (); varURL ="http://bj.58.com/"; P.asynchronous (URL); P.multithread (URL); Console.readkey (); } voidAsynchronous (stringURL) { varRequest =httpwebrequest.create (URL); Request. BeginGetResponse (IAsyncResult ar)= { varRequest_inner = ar. AsyncState asWebRequest; varResponse =request. EndGetResponse (AR); Read (response,"Asynchronous"); }, request); } voidMultithread (stringURL) { vart =NewThread (() = { varRequest =httpwebrequest.create (URL); varResponse =request. GetResponse (); Read (response,"multithread"); }); T.start (); } Private Static voidRead (WebResponse response,stringfuncname) { varstream =Response. GetResponseStream (); using(varReader =NewStreamReader (Stream)) {Console.WriteLine ("{0} {1}", FuncName, reader. ReadToEnd (). Length); } } }}
The difference between async and multithreading