public static void RunMethod(IExecutionHandler executionHandler)
        {
            if (!IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted)
            {
                if (!MessageService.Confirm(GettextCatalog.GetString("An application is already running. Do you want to stop it?"), AlertButton.Stop))
                {
                    return;
                }
                StopHandler.StopBuildOperations();
                IdeApp.ProjectOperations.CurrentRunOperation.WaitForCompleted();
            }

            if (!IdeApp.Workspace.IsOpen)
            {
                if (!IdeApp.Preferences.BuildBeforeExecuting)
                {
                    IdeApp.Workbench.ActiveDocument.Run(executionHandler);
                }
                else
                {
                    IAsyncOperation asyncOperation = IdeApp.Workbench.ActiveDocument.Build();
                    asyncOperation.Completed += delegate
                    {
                        if ((asyncOperation.Success) || (IdeApp.Preferences.RunWithWarnings && asyncOperation.SuccessWithWarnings))
                        {
                            IdeApp.Workbench.ActiveDocument.Run(executionHandler);
                        }
                    };
                }
            }
            else
            {
                if (!IdeApp.Preferences.BuildBeforeExecuting)
                {
                    IdeApp.ProjectOperations.Execute(IdeApp.ProjectOperations.CurrentSelectedSolution, executionHandler);
                }
                else
                {
                    Solution        sol            = IdeApp.ProjectOperations.CurrentSelectedSolution;
                    IAsyncOperation asyncOperation = IdeApp.ProjectOperations.Build(sol);
                    asyncOperation.Completed += delegate
                    {
                        if ((asyncOperation.Success) || (IdeApp.Preferences.RunWithWarnings && asyncOperation.SuccessWithWarnings))
                        {
                            IdeApp.ProjectOperations.Execute(sol, executionHandler);
                        }
                    };
                }
            }
        }
Exemplo n.º 2
0
        public static async void RunMethod(IExecutionHandler executionHandler)
        {
            if (!IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted)
            {
                if (!MessageService.Confirm(GettextCatalog.GetString("An application is already running. Do you want to stop it?"), AlertButton.Stop))
                {
                    return;
                }
                StopHandler.StopBuildOperations();
                await IdeApp.ProjectOperations.CurrentRunOperation.Task;
            }

            if (IdeApp.Workspace.IsOpen)
            {
                var target = GetRunTarget();
                IdeApp.ProjectOperations.Execute(target, executionHandler, true);
            }
        }