public void Dispose() { if (_operation != null) { _operation.Dispose(); _operation = null; } if (_notificationService != null) { _notificationService = null; KnownUIContexts.SolutionBuildingContext.UIContextChanged -= SolutionBuildingContextChanged; } }
private void TrackBulkFileOperations() { // we will pause whatever ambient work loads we have that are tied to IGlobalOperationNotificationService // such as solution crawler, pre-emptive remote host synchronization and etc. any background work users didn't // explicitly asked for. // // this should give all resources to BulkFileOperation. we do same for things like build, // debugging, wait dialog and etc. BulkFileOperation is used for things like git branch switching and etc. var globalNotificationService = _workspace.Services.GetService <IGlobalOperationNotificationService>(); // BulkFileOperation can't have nested events. there will be ever only 1 events (Begin/End) // so we only need simple tracking. object gate = new object(); GlobalOperationRegistration localRegistration = null; BulkFileOperation.End += (s, a) => { StopBulkFileOperationNotification(); }; BulkFileOperation.Begin += (s, a) => { StartBulkFileOperationNotification(); }; void StartBulkFileOperationNotification() { lock (gate) { // this shouldn't happen, but we are using external component // so guarding us from them if (localRegistration != null) { WatsonReporter.Report(new Exception("BulkFileOperation already exist")); return; } localRegistration = globalNotificationService.Start("BulkFileOperation"); } } void StopBulkFileOperationNotification() { lock (gate) { // this can happen if BulkFileOperation was already in the middle // of running. to make things simpler, decide to not use IsInProgress // which we need to worry about race case. if (localRegistration == null) { return; } localRegistration.Dispose(); localRegistration = null; } } }
public void Dispose() { _dialog.EndWaitDialog(out var canceled); if (canceled == 0) { _registration.Done(); } _registration.Dispose(); }
public void Dispose() { _dialog.EndWaitDialog(out var canceled); // Let the global operation object know that we completed with/without user cancelling. If the user // canceled, we won't call 'Done', and so calling 'Dispose' will log that we didn't complete fully. if (canceled == 0) { _registration.Done(); } _registration.Dispose(); }