0

我有一个调用 WPF 4.0 dll 的 VB6 exe。
在我的 WPF dll 中,我有一个需要更新 UI 的后台工作人员。
我似乎无法回到 UI 线程,因为 Application.Current 为空。

Application app = Application.Current;
if (app != null)
{
  Dispatcher disp = app.Dispatcher;
  if (disp != null)
  {
    if (!disp.CheckAccess())
    {
    }
    else
    {
    }
  }
}

我也尝试过 Dispatcher.CurrentDispatcher 但这也没有将我切换到 UI 线程。

有谁知道当 VB6 exe 调用 WPF dll 时如何切换到 WPF 中的 UI 线程?

4

1 回答 1

1

在进入 WPF 端时存储 Dispatcher.CurrentDispatcher,以便您可以从 BackgroundWorker 中使用它。

于 2012-10-24T00:16:54.550 回答