WEB-приложения на основе. NET MVC 3 установить C# асинхронных рабочее значение ошибки, код следующим образом:Ошибка операции асинхронной обработки C#
public ActionResult Contact()
{
// Create an asynchronous processing operations
Task task = new Task (() => {
string [] testTexts = new string [10] {"a", "b", "c", "d", "e", "f", "g", "h" , "i", "j"};
foreach (string text in testTexts)
{
// The following line does not have a problem
System.IO.File.AppendAllText (Server.MapPath ("/ test.txt"), text);
// The following line to be a problem, find a solution. Because some other program of practical application in my project set to use System.Web.HttpContext.Current
// System.IO.File.AppendAllText (System.Web.HttpContext.Current.Server.MapPath ("/ test.txt"), text);
// Thread to hang five seconds to simulate asynchronous time difference
System.Threading.Thread.Sleep (5000);
}
});
// Asynchronous processing
task.Start();
return View();
}
System.Web.HttpContext.Current, почему вы используете эту строку, что вы хотите точно –