我的应用程序挂在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
}));
}