Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions Plugins/Flow.Launcher.Plugin.ProcessKiller/Main.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Flow.Launcher.Infrastructure;
using System.Threading.Tasks;

namespace Flow.Launcher.Plugin.ProcessKiller
{
Expand Down Expand Up @@ -89,7 +88,8 @@ private List<Result> CreateResultsFromQuery(Query query)
Action = (c) =>
{
processHelper.TryKill(p);
_ = DelayAndReQueryAsync(query.RawQuery); // Re-query after killing process to refresh process list
// Re-query to refresh process list
_context.API.ChangeQuery(query.RawQuery, true);
return true;
}
});
Expand All @@ -114,19 +114,14 @@ private List<Result> CreateResultsFromQuery(Query query)
{
processHelper.TryKill(p.Process);
}
_ = DelayAndReQueryAsync(query.RawQuery); // Re-query after killing process to refresh process list
// Re-query to refresh process list
_context.API.ChangeQuery(query.RawQuery, true);
return true;
}
});
}

return sortedResults;
}

private static async Task DelayAndReQueryAsync(string query)
{
await Task.Delay(500);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity why the delay before re-query?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was to wait for process exit. Didn't realize I could do it the way in this PR.

_context.API.ChangeQuery(query, true);
}
}
}
3 changes: 2 additions & 1 deletion Plugins/Flow.Launcher.Plugin.ProcessKiller/ProcessHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Logger;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -75,6 +75,7 @@ public void TryKill(Process p)
if (!p.HasExited)
{
p.Kill();
p.WaitForExit(50);
}
}
catch (Exception e)
Expand Down