0

我的应用程序挂在这条线上 this.SFprogress.Value = 20;// this is a progress bar,它没有在 Visual Studio 上引发任何错误。

每次在 SalesForceExporter 类中引发事件“RecordPosted”时,我只是试图更新进度条。我是线程 wpf 的新手,对此我感到很困惑,任何帮助将不胜感激。

{ 
        var export = new SalesForceExporter(ItemsSource);
        export.RecordPosted += export_RecordPosted;
        Thread oThread = new Thread(new ThreadStart(export.Export));
        oThread.IsBackground = true;
        oThread.Start();

 }
       void export_RecordPosted(object sender, RecordPostEventArgs e)
    {
        UpdateProgress(e.RecordNumber, e.BatchSize);

    }

    private void UpdateProgress(int currntCount, int totalCount)
    {
        if (totalCount > 0)
        {
            //this.Dispatcher.Invoke((Action<int,int>)((x,y) => { SFprogress.Value = 100d; }),currntCount,totalCount);
            this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate()
            {
                this.SFprogress.Value = 20; // this is a progress bar
            }));
        }
4

0 回答 0