我有一个程序通过 API 向我推送股票报价。该程序还有一个用 XAML 制作的前端,它在程序运行时冻结(即处理 API 发送给我的信息)。我已经尝试使用 Dispatcher.Invoke 和/或 BackgroundWorker 并且已经阅读了大量线程,但无法将其解冻。也许我只是做错了什么。我在这里附上了相关的代码。希望有人能帮忙。
    private void QuoteUpdate(QuoteInfo info)
    {
        BackgroundWorker bwQuoteUpdate = new BackgroundWorker();
        bwQuoteUpdate = new BackgroundWorker();
        bwQuoteUpdate.WorkerSupportsCancellation = true;
        bwQuoteUpdate.DoWork += bwQuoteUpdate_DoWork;            
        bwQuoteUpdate.RunWorkerAsync(info);         
    }
    private void bwQuoteUpdate_DoWork(object sender, DoWorkEventArgs e)
    {
        try
        {
            Dispatcher.Invoke(DispatcherPriority.Normal, new ThreadStart(() =>
            {
                QuoteInfo info = e.Argument as QuoteInfo;
                //logical functions and work are here
            }));
        }
        catch (Exception ex)
        {
            System.Windows.Forms.MessageBox.Show("Error in QuoteUpdate: " + ex.Message, "Exception Thrown");
        }
    }