private void UpdatePreview() { if (_suppressPreview) { return; } if (_condaMgr == null) { return; } if (IsEnvFile && IsPackages) { // Temporary state while switching from one combo box to the other // We'll get called again with only one of them set to true return; } _updatePreviewCancelTokenSource?.Cancel(); _updatePreviewCancelTokenSource = new CancellationTokenSource(); // Clear the preview, display a progress icon/message var p = new CondaEnvironmentPreview(); p.Progress.IsProgressDisplayed = true; CondaPreview = p; var envName = EnvName ?? string.Empty; if (IsEnvFile) { var envFilePath = SelectedEnvFilePath ?? string.Empty; Task.Run(() => UpdatePreviewAsync(envName, envFilePath, _updatePreviewCancelTokenSource.Token)).HandleAllExceptions(Site, typeof(AddCondaEnvironmentView)).DoNotWait(); } else if (IsPackages) { var specs = PackagesSpecs.ToArray(); Task.Run(() => UpdatePreviewAsync(envName, specs, _updatePreviewCancelTokenSource.Token)).HandleAllExceptions(Site, typeof(AddCondaEnvironmentView)).DoNotWait(); } }
public override async Task ApplyAsync() { if (_condaMgr == null) { return; } var operation = new AddCondaEnvironmentOperation( Site, _condaMgr, SelectedProject?.Node, EnvName, IsEnvFile ? SelectedEnvFilePath : null, IsPackages ? PackagesSpecs.ToList() : Enumerable.Empty <PackageSpec>().ToList(), SetAsCurrent, SetAsDefault, ViewInEnvironmentWindow ); await operation.RunAsync(); }