private void StartUpdateChart(List <LogMessage> messages) { if (messages != null && messages.Count > 0) { UpdateChartDelegate worker = UpdateChartWorker; AsyncCallback completedCallback = UpdateChartCallback; lock (mSyncRoot) { if (mInUpdate) { return; } // Create the asynchronous operation. AsyncOperation async = AsyncOperationManager.CreateOperation(null); // And start it. worker.BeginInvoke( messages , completedCallback , async); mInUpdate = true; } } }
private void UpdateChartCallback(IAsyncResult ar) { UpdateChartDelegate worker = (UpdateChartDelegate)((AsyncResult)ar).AsyncDelegate; // Finish the asynchronous operation worker.EndInvoke(ar); BeginInvoke(new Action(EndUpdateChart)); }