我为异步控制器创建了一个程序。但遗憾的是无法执行该程序。在运行该程序时,它说 -
' /'中的服务器错误应用
无法找到资源。
以下是控制器的代码 -
public class AsyncDemoController : AsyncController
{
private readonly object _lock = new object();
public void IndexAysnc()
{
AsyncManager.OutstandingOperations.Increment(2);
Operation1();
Operation2();
}
public ActionResult IndexCompleted(string Operation1, string Operation2)
{
ViewData["Operation1"] = Operation1;
ViewData["Operation2"] = Operation2;
return View("Index");
}
void Operation1()
{
lock (_lock)
{
AsyncManager.Parameters["Operation1"] = "Result1";
}
AsyncManager.OutstandingOperations.Decrement();
}
void Operation2()
{
lock (_lock)
{
AsyncManager.Parameters["Operation2"] = "Result2";
}
AsyncManager.OutstandingOperations.Decrement();
}
}
我一定错过了什么。请建议。
先谢谢。