What you have to is to have a TaskStatus type object in server side maybe in session or new the Profile:
For Ex You have a WebService:
[WebMethod(EnableSession=true]
void ProcessLongRunningTask()
{
TaskStatus status = new TaskStatus();
Session["status"] = status;
PerfromStep1(status);
PerfromStep2(status);
//And So On
}
void PerfromStep1(TaskStatus status)
{
//Process your work
status.Progress += 10;
}
void PerfromStep2(TaskStatus status)
{
//Process your work
status.Progress += 20;
}
Then Say We have also a method which returns a task status, like this
[WebMethod(EnableSession=true]
TaskStatus GetTaskStatus()
{
return (TaskStatus) Session["status"]
}
In the Client Side say you start the by calling the ProcessLongRunningTask Method. Then you use the window.setInterval to poll the Task Status at predefined interval by calling the GetTaskStatus() method.
I hope i have explained the idea.
No comments:
Post a Comment