这是IssueSubject.cs类中的方法,看不懂OnDoWork和OnCompleted里面的方法是做什么的,求助高手们帮帮我.
// BackgroundWorkerThread.DoWork: this method is run on the background thread to do its work
private void OnDoWork(object sender, DoWorkEventArgs doWorkArgs)
{
DateTime lastAccessed = (DateTime)doWorkArgs.Argument;
doWorkArgs.Result = GetNewIssues(lastAccessed);
} // sends and received data to/from the web service
private IVDataSet GetNewIssues(DateTime lastAccessed)
{
IVDataSet newIssues = null;
try
{
DataSet changesDataSet = m_dataSet.GetChanges(DataRowState.Added | DataRowState.Modified);
newIssues = WebServicesLayer.SendReceiveIssues(changesDataSet, lastAccessed);
}
catch
{
// Eat this exception. It is logged on the service side, and the caller of this
// method tests if newIssues is null to decide whether the service is currently
// available.
}
return newIssues;
} // BackgroundWorkerThread.RunWorkerCompleted: This method runs on the timer thread
// when the background thread finishes it's work
private void OnCompleted(object sender, RunWorkerCompletedEventArgs completedArgs)
{
// newIssues is return from the background thread to the timer thread
IVDataSet newIssues = (IVDataSet)completedArgs.Result;
// Parent.Invoke passes the newIssues data to MergeNewIssues on the MainForm thread
m_parent.Invoke(new DataChanged(this.MergeNewIssues), new object[]{newIssues});
}
// BackgroundWorkerThread.DoWork: this method is run on the background thread to do its work
private void OnDoWork(object sender, DoWorkEventArgs doWorkArgs)
{
DateTime lastAccessed = (DateTime)doWorkArgs.Argument;
doWorkArgs.Result = GetNewIssues(lastAccessed);
} // sends and received data to/from the web service
private IVDataSet GetNewIssues(DateTime lastAccessed)
{
IVDataSet newIssues = null;
try
{
DataSet changesDataSet = m_dataSet.GetChanges(DataRowState.Added | DataRowState.Modified);
newIssues = WebServicesLayer.SendReceiveIssues(changesDataSet, lastAccessed);
}
catch
{
// Eat this exception. It is logged on the service side, and the caller of this
// method tests if newIssues is null to decide whether the service is currently
// available.
}
return newIssues;
} // BackgroundWorkerThread.RunWorkerCompleted: This method runs on the timer thread
// when the background thread finishes it's work
private void OnCompleted(object sender, RunWorkerCompletedEventArgs completedArgs)
{
// newIssues is return from the background thread to the timer thread
IVDataSet newIssues = (IVDataSet)completedArgs.Result;
// Parent.Invoke passes the newIssues data to MergeNewIssues on the MainForm thread
m_parent.Invoke(new DataChanged(this.MergeNewIssues), new object[]{newIssues});
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货