Fix lock release issue

This commit is contained in:
Jack251970 2025-04-08 16:59:27 +08:00
parent 87aca2ffef
commit 734c5bb67d

View file

@ -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<ProcessStartInfo, Process> runProcess, ProcessStartInfo info)