public void IndexAsync()
{
AsyncManager.OutstandingOperations.Increment(2);
Task.Factory.StartNew(() => {
string url = "http://www.cnblogs.com";
WebClient client = new WebClient();
string reply=client.DownloadString(url);
System.Threading.Thread.Sleep(10000);
AsyncManager.Parameters["data"] = reply;
AsyncManager.OutstandingOperations.Decrement();
});
Task.Factory.StartNew(() => {
string url = "http://s.189180.net";
WebClient client = new WebClient();
string reply = client.DownloadString(url);
System.Threading.Thread.Sleep(10000);
AsyncManager.Parameters["data"] = reply;
AsyncManager.OutstandingOperations.Decrement();
});
}
public ActionResult IndexCompleted(string data, string moredata)
{
Operations translations = new Operations() { FirstOperation = "Data", SecondOperation = "moredata" };
return View(translations);
}
转载于:https://www.cnblogs.com/xmyy/articles/2891129.html