Здравствуйте, я пытаюсь реализовать AsynController,
вот мой код:
[NoCache]
public class GraphController : BaseAsyncController
{
private readonly IReportsRepository _reportsRepository;
private readonly ISqlQueryRepository _sqlQueryRepository;
//Background worker
private readonly BackgroundWorker _worker = new BackgroundWorker();
public GraphController(ISqlQueryRepository sqlQueryRepository, IReportsRepository reportsRepository)
{
_sqlQueryRepository = sqlQueryRepository;
_reportsRepository = reportsRepository;
}
public void Index()
{
AsyncManager.OutstandingOperations.Increment();
_worker.DoWork += (sender, args) =>
{
AsyncManager.Parameters["message"] = "hello world";
Thread.Sleep(3000);
};
_worker.RunWorkerCompleted += (sender, args) => AsyncManager.OutstandingOperations.Decrement();
//run the worker
_worker.RunWorkerAsync();
}
public ActionResult IndexCompleted(string message) //callback not being invoked
{
ViewData["message"] = message;
return View();
}
}
Вопрос в том, почему завершенный обратный вызов не вызывается?
Заранее спасибо.