void RunActionsWithProgressMonitor(
     ProgressMonitorStatusMessage progressMessage,
     IList <IPackageAction> installPackageActions,
     TaskCompletionSource <bool> taskCompletionSource,
     bool clearConsole,
     CancellationTokenSource cancellationTokenSource)
 {
     using (ProgressMonitor monitor = progressMonitorFactory.CreateProgressMonitor(progressMessage.Status, clearConsole, cancellationTokenSource)) {
         using (PackageManagementEventsMonitor eventMonitor = CreateEventMonitor(monitor, taskCompletionSource)) {
             try {
                 monitor.BeginTask(null, installPackageActions.Count);
                 RunActionsWithProgressMonitor(monitor, installPackageActions);
                 eventMonitor.ReportResult(progressMessage);
             } catch (Exception ex) {
                 RemoveInstallActions(installPackageActions);
                 bool showPackageConsole = !monitor.CancellationToken.IsCancellationRequested;
                 eventMonitor.ReportError(progressMessage, ex, showPackageConsole);
             } finally {
                 monitor.EndTask();
                 GuiDispatch(() => {
                     RemoveInstallActions(installPackageActions);
                     packageManagementEvents.OnPackageOperationsFinished();
                 });
             }
         }
     }
 }
        void RunInternal()
        {
            progressMessage = CreateCheckingPackageCompatibilityMessage();

            using (progressMonitor = CreateProgressMonitor()) {
                using (PackageManagementEventsMonitor eventMonitor = CreateEventMonitor(progressMonitor)) {
                    try {
                        CheckCompatibility();
                    } catch (Exception ex) {
                        eventMonitor.ReportError(progressMessage, ex);
                    }
                }
            }
        }
Пример #3
0
 public void Run(ProgressMonitorStatusMessage progressMessage)
 {
     using (ProgressMonitor progressMonitor = CreateProgressMonitor(progressMessage)) {
         using (PackageManagementEventsMonitor eventMonitor = CreateEventMonitor(progressMonitor)) {
             try {
                 RestorePackages(progressMonitor, progressMessage);
             } catch (Exception ex) {
                 LoggingService.LogError(progressMessage.Error, ex);
                 progressMonitor.Log.WriteLine(ex.Message);
                 progressMonitor.ReportError(progressMessage.Error, null);
                 progressMonitor.ShowPackageConsole();
                 progressMonitor.Dispose();
                 RestoreFailed = true;
             }
         }
     }
 }
 void RunActionsWithProgressMonitor(ProgressMonitorStatusMessage progressMessage, IList <IPackageAction> installPackageActions)
 {
     using (IProgressMonitor monitor = progressMonitorFactory.CreateProgressMonitor(progressMessage.Status)) {
         using (PackageManagementEventsMonitor eventMonitor = CreateEventMonitor(monitor)) {
             try {
                 monitor.BeginTask(null, installPackageActions.Count);
                 RunActionsWithProgressMonitor(monitor, installPackageActions);
                 eventMonitor.ReportResult(progressMessage);
             } catch (Exception ex) {
                 RemoveInstallActions(installPackageActions);
                 eventMonitor.ReportError(progressMessage, ex);
             } finally {
                 monitor.EndTask();
                 GuiDispatch(() => {
                     RemoveInstallActions(installPackageActions);
                     packageManagementEvents.OnPackageOperationsFinished();
                 });
             }
         }
     }
 }
		void RunActionsWithProgressMonitor (ProgressMonitorStatusMessage progressMessage, IList<IPackageAction> installPackageActions)
		{
			using (IProgressMonitor monitor = progressMonitorFactory.CreateProgressMonitor (progressMessage.Status)) {
				using (var eventMonitor = new PackageManagementEventsMonitor (monitor, packageManagementEvents, PackageManagementServices.ProgressProvider)) {
					try {
						monitor.BeginTask (null, installPackageActions.Count);
						RunActionsWithProgressMonitor (monitor, installPackageActions);
						eventMonitor.ReportResult (progressMessage);
					} catch (Exception ex) {
						RemoveInstallActions (installPackageActions);
						eventMonitor.ReportError (progressMessage, ex);
					} finally {
						monitor.EndTask ();
						DispatchService.GuiDispatch (() => {
							RemoveInstallActions (installPackageActions);
							packageManagementEvents.OnPackageOperationsFinished ();
						});
					}
				}
			}
		}