开发者

Signaling web page when ThreadPool thread is completed

开发者 https://www.devze.com 2023-01-13 17:15 出处:网络
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:

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 progres开发者_Go百科s 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?


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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消