public void BeginSync(SyncThread behavior) { if (OnSyncStart != null) OnSyncStart(this, EventArgs.Empty); if (behavior == SyncThread.BackgroundThread) { bgThreadState = BackgroundThreadState.Running; worker.RunWorkerAsync(); } else { List<ProductInfo> products = GetNewData(); MergeNewData(products); } }
public PMSubject(ISynchronizeInvoke syncInvoker) { InitializeComponent(); this.syncInvoker = syncInvoker; bgThreadState = BackgroundThreadState.None; }
private void MergeNewData(List<ProductInfo> products) { if (products != null && products.Count > 0) { if (OnNewData != null) OnNewData(this, new NewDataEventArgs(products)); } bgThreadState = BackgroundThreadState.Stop; if (OnSyncCompleted != null) OnSyncCompleted(this, EventArgs.Empty); }