Repository: microsoft/PowerToys
File: src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Apps/Commands/UninstallApplicationCommand.cs (C#)

Code before:
        _uwpTarget = target ?? throw new ArgumentNullException(nameof(target));
    }

    public UninstallApplicationCommand(Win32Program target)
    {
        Name = Resources.uninstall_application;
        Icon = Icons.UninstallApplicationIcon;
        _win32Target = target ?? throw new ArgumentNullException(nameof(target));
    }

    private async Task<CommandResult> UninstallUwpAppAsync(UWPApplication app)
    {
        if (string.IsNullOrWhiteSpace(app.Package.FullName))
        {
            Logger.LogError($"Critical error while uninstalling: packageFullName cannot be null or empty.");
            return CommandResult.ShowToast(new ToastArgs()
            {
                Message = string.Format(CultureInfo.CurrentCulture, CompositeFormat.Parse(Resources.uninstall_application_failed), app.DisplayName),
                Result = CommandResult.KeepOpen(),
            });
        }

        try
        {
            // Which timeout to use for the uninstallation operation?
            using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(60));
            {
                var packageManager = new PackageManager();
                var result = await packageManager.RemovePackageAsync(app.Package.FullName).AsTask(cts.Token);

                if (result.ErrorText is not null && result.ErrorText.Length > 0)
                {
                    Logger.LogError($"Failed to uninstall {app.Package.FullName}: {result.ErrorText}");
                    return CommandResult.ShowToast(new ToastArgs()
                    {
                        Message = string.Format(CultureInfo.CurrentCulture, CompositeFormat.Parse(Resources.uninstall_application_failed), app.DisplayName),
                        Result = CommandResult.KeepOpen(),
                    });
                }
            }

            // TODO: Update the Search results after uninstalling the app - unsure how to do this yet.
            return CommandResult.ShowToast(new ToastArgs()
            {
                Message = string.Format(CultureInfo.CurrentCulture, CompositeFormat.Parse(Resources.uninstall_application_successful), app.DisplayName),
                Result = CommandResult.KeepOpen(),
            });
        }
        catch (OperationCanceledException)
        {
            Logger.LogError($"Timeout exceeded while uninstalling {app.Package.FullName}");

Review comment (suggestion):
I believe you wanted to do this instead:
```suggestion
            using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(60)))
```

Code after:
        _uwpTarget = target ?? throw new ArgumentNullException(nameof(target));
    }

    public UninstallApplicationCommand(Win32Program target)
    {
        Name = Resources.uninstall_application;
        Icon = Icons.UninstallApplicationIcon;
        _win32Target = target ?? throw new ArgumentNullException(nameof(target));
    }

    private async Task<CommandResult> UninstallUwpAppAsync(UWPApplication app)
    {
        if (string.IsNullOrWhiteSpace(app.Package.FullName))
        {
            Logger.LogError($"Critical error while uninstalling: packageFullName cannot be null or empty.");
            return CommandResult.ShowToast(new ToastArgs()
            {
                Message = string.Format(CultureInfo.CurrentCulture, CompositeFormat.Parse(Resources.uninstall_application_failed), app.DisplayName),
                Result = CommandResult.KeepOpen(),
            });
        }

        try
        {
            // Which timeout to use for the uninstallation operation?
            using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(60)))
            {
                var packageManager = new PackageManager();
                var result = await packageManager.RemovePackageAsync(app.Package.FullName).AsTask(cts.Token);

                if (result.ErrorText is not null && result.ErrorText.Length > 0)
                {
                    Logger.LogError($"Failed to uninstall {app.Package.FullName}: {result.ErrorText}");
                    return CommandResult.ShowToast(new ToastArgs()
                    {
                        Message = string.Format(CultureInfo.CurrentCulture, CompositeFormat.Parse(Resources.uninstall_application_failed), app.DisplayName),
                        Result = CommandResult.KeepOpen(),
                    });
                }
            }

            // TODO: Update the Search results after uninstalling the app - unsure how to do this yet.
            return CommandResult.ShowToast(new ToastArgs()
            {
                Message = string.Format(CultureInfo.CurrentCulture, CompositeFormat.Parse(Resources.uninstall_application_successful), app.DisplayName),
                Result = CommandResult.GoHome(),
            });
        }
        catch (OperationCanceledException)
        {
            Logger.LogError($"Timeout exceeded while uninstalling {app.Package.FullName}");