无法在 Wpf 中使用 BackgroundWorker 运行 BusyIndi​​cator

Not able to run BusyIndicator with BackgroundWorker in Wpf

我有两个windows。我的主窗口和带有 busyIndi​​cator 的 window。 我正在使用 BackgroundWorker 和 Dispatcher 来完成主要 window 中的工作(计算和 ui),同时我想显示 busyIndi​​cator。但只有 window 显示而没有 busyIndi​​cator。

        BusyIndicator_Window busy = new BusyIndicator_Window();
        busy.Show();


        BackgroundWorker worker = new BackgroundWorker();

        worker.DoWork += (o, ea) =>
        {

            Dispatcher.Invoke((Action)(() =>
                {
                    Plot.Plot_MV.startAnke(selectedFilePath, lw);

                }));
        };

        worker.RunWorkerCompleted += (o, ea) =>
        {
            busy.busyIndicator.IsBusy = false;
        };

        busy.busyIndicator.IsBusy = true;
        worker.RunWorkerAsync(); 

我有什么不对的地方吗? 谢谢

立即委托回 UI 线程的后台工作人员非常无用。只做你想做的工作:

worker.DoWork += (o, ea) =>
{
  Plot.Plot_MV.startAnke(selectedFilePath, lw);
};