private async Task Launch() { //DeploymentTask task = null; ClouderSyncPackage.WriteToOutputWindow("-----\n", "ClouderSync", null, true); if (!ConnectEntryData.SettingsExist()) { ShowMessageBox(@"It does not appear that SFTP connection has been configured. Please configure in the next step", "ClouderSync SSH"); cmdConfigureSSH.ConfigureSSH(this); return; } if (DeploymentTask.GetIsRunning()) { ShowMessageBox(@"It appears that a deployment task is running. Please cancel, or wait, or restart Visual Studio", "ClouderSync SSH"); return; } CancellationTokenSource tokenSource = new CancellationTokenSource(); CancellationToken token = tokenSource.Token; DeploymentTask task = new DeploymentTask(this); await Task.Run(() => { task.Execute(tokenSource); }); }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void Execute(object sender, EventArgs e) { if (!DeploymentTask.GetIsRunning()) { Launch(); } else { Cancel(); } }
protected override void OnBeforeQueryStatus(object sender, EventArgs e) { var myCommand = sender as OleMenuCommand; if (myCommand != null) { if (myCommand.CommandID.ID == ClouderSyncIDs.cmdidCloudDeploy || myCommand.CommandID.ID == ClouderSyncIDs.cmdidCancelDeploy) { if (DeploymentTask.GetIsRunning()) { myCommand.Text = @"Cancel deployment over SSH/SFTP"; } else { myCommand.Text = @"Deploy over SSH/SFTP"; } } } }