private async void Launch() { //CompressTask 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 (CompressTask.GetIsRunning()) { ShowMessageBox(@"It appears that a compression task is running. Please cancel, or wait, or restart Visual Studio", "ClouderSync Compress"); return; } CancellationTokenSource tokenSource = new CancellationTokenSource(); CancellationToken token = tokenSource.Token; CompressTask task = new CompressTask(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 (!CompressTask.GetIsRunning()) { Launch(); } else { Cancel(); } }
private void backgroundWorker_DoWork(object sender, DoWorkEventArgs eArgs) { CompressTask task = null; if (eArgs.Argument is CompressTask) { task = eArgs.Argument as CompressTask; } if (task != null) { task.Execute(); } else { string message = string.Format(CultureInfo.CurrentCulture, "Failed to pass SFTP CompressTask {0}", this.GetType().FullName); ShowMessageBox(message, "ClouderSync Deploy"); } }
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 (CompressTask.GetIsRunning()) { myCommand.Text = @"Cancel file compression"; } else { myCommand.Text = @"Compress files to archive"; } } } }
private async void Cancel() { ClouderSyncPackage.WriteToOutputWindow("\nCancellation requested \n", "ClouderSync", null, false); CompressTask.Cancel(); }