开发者

progressbar IsIndeterminate not working while other heavy task running

开发者 https://www.devze.com 2023-02-21 03:03 出处:网络
I use the following code to update my progressBar when using min and max values while doing some heavy tasks and it works fine. I have a few tasks that can not provide

I use the following code to update my progressBar when using min and max values while doing some heavy tasks and it works fine. I have a few tasks that can not provide a update status by increment value, so I wanted to use IsIndeterminate so it shows something is going on. When I set it to IsIndeterminate it freezes while the heavy task is running. What is the best way to get a progressbar to run in IsInd开发者_如何学JAVAeterminate. I tried using a DispatchTimer, but the tick was never called while the heavy task was running. I'm curious what the best way to handle this would be. Thanks for any help.

public static class extensionRefresh {
    private static Action EmptyDelegate = delegate() { };
    public static void Refresh(this UIElement uiElement) {
    uiElement.Dispatcher.Invoke(DispatcherPriority.Background, EmptyDelegate);
    }
}


Sounds to me like you are blocking the UI thread, and that's why the progress bar gets stuck.

Use BackgroundWorker if you want to do a long task, so that way it uses a worker thread and the progress bar would work

0

精彩评论

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