Вы можете сделать это с помощью 2 методов действия и таймера JavaScript
[HttpPost]
public JsonResult StartProcess()
{
StartTheMachine();
return new JsonResult() { Data = "Started" };
}
[HttpGet]
public JsonResult GetProcessUpdate()
{
return new JsonResult()
{
Data = GetUpdate(),
JsonRequestBehavior = JsonRequestBehavior.AllowGet
};
}
и, на ваш взгляд, что-то вроде этого:
$.post("<%=Url.Action("StartProcess") %>", function(data) {
// do something with data "Started" and start timer
setTimeout(GetUpdate, 5000);
});
function GetUpdate()
{
$.get("<%=Url.Action("GetUpdate") %>", function(data) {
if (data.Complete) // or some way to tell it has finished
{
// do something with other data returned
}
else
{
// call again if not finished
setTimeout(GetUpdate, 5000);
}
});
}