From 734c5bb67deb769190fa46572083e64ffcef8cf8 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Tue, 8 Apr 2025 16:59:27 +0800 Subject: [PATCH] Fix lock release issue --- Plugins/Flow.Launcher.Plugin.Program/Main.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Main.cs b/Plugins/Flow.Launcher.Plugin.Program/Main.cs index 6d2ae70fc..a5fbc6c70 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Main.cs @@ -367,7 +367,7 @@ namespace Flow.Launcher.Plugin.Program Title = Context.API.GetTranslation("flowlauncher_plugin_program_disable_program"), Action = c => { - DisableProgram(program); + _ = DisableProgramAsync(program); Context.API.ShowMsg( Context.API.GetTranslation("flowlauncher_plugin_program_disable_dlgtitle_success"), Context.API.GetTranslation( @@ -383,7 +383,7 @@ namespace Flow.Launcher.Plugin.Program return menuOptions; } - private static async Task DisableProgram(IProgram programToDelete) + private static async Task DisableProgramAsync(IProgram programToDelete) { if (_settings.DisabledProgramSources.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier)) return; @@ -403,7 +403,12 @@ namespace Flow.Launcher.Plugin.Program }); return; } - + else + { + // Release the lock if we cannot find the program + _uwpsLock.Release(); + } + await _win32sLock.WaitAsync(); if (_win32s.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier)) { @@ -418,6 +423,11 @@ namespace Flow.Launcher.Plugin.Program _ = IndexWin32ProgramsAsync(); }); } + else + { + // Release the lock if we cannot find the program + _win32sLock.Release(); + } } public static void StartProcess(Func runProcess, ProcessStartInfo info)