views:

13

answers:

1

From a web page I start a time consuming job and update it's status on the UI using webmethod.

Job is done in a thread:

ThreadPool.QueueUserWorkItem(new WaitCallback(DoJob), parameters);

Job set's it status using static properties, and when web page, using javascript, calls web method it read those properties.

 [System.Web.Services.WebMethod]
    public static ProcessStatus GetProgressStatus()
    {

        Jober.Lock.EnterReadLock();
        ProcessStatus st = new ProcessStatus(Jober.PercentageCompleted, Jober.TotalNumber);
        Jober.Lock.ExitReadLock();

        return st;
    }

The UI progress is updated through javascript, the problem is that after thread completes I need to update UI on server side, so javascript won't help me here.

What Is the best way to signal when thread is completed?

A: 

You say that "The UI progress is updated through javascript".

Couldn't you just make the page reload (using javascript) when Jober.PercentageCompleted == 100?

Andreas Paulsson