mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use string builder
This commit is contained in:
parent
f25c5b9b05
commit
aa6c9d91cf
1 changed files with 11 additions and 5 deletions
|
|
@ -3,6 +3,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.Foundation;
|
||||
using Windows.Win32.System.Threading;
|
||||
|
|
@ -31,15 +32,20 @@ namespace Flow.Launcher.Plugin.ProcessKiller
|
|||
|
||||
private const string FlowLauncherProcessName = "Flow.Launcher";
|
||||
|
||||
private bool IsSystemProcess(Process p) => _systemProcessList.Contains(p.ProcessName.ToLower()) ||
|
||||
string.Compare(p.ProcessName, FlowLauncherProcessName, StringComparison.OrdinalIgnoreCase) == 0;
|
||||
private bool IsSystemProcessOrFlowLauncher(Process p) =>
|
||||
_systemProcessList.Contains(p.ProcessName.ToLower()) ||
|
||||
string.Equals(p.ProcessName, FlowLauncherProcessName, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// Get title based on process name and id
|
||||
/// </summary>
|
||||
public static string GetProcessNameIdTitle(Process p)
|
||||
{
|
||||
return p.ProcessName + " - " + p.Id;
|
||||
var sb = new StringBuilder();
|
||||
sb.Append(p.ProcessName);
|
||||
sb.Append(" - ");
|
||||
sb.Append(p.Id);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -51,7 +57,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller
|
|||
|
||||
foreach (var p in Process.GetProcesses())
|
||||
{
|
||||
if (IsSystemProcess(p)) continue;
|
||||
if (IsSystemProcessOrFlowLauncher(p)) continue;
|
||||
|
||||
processlist.Add(p);
|
||||
}
|
||||
|
|
@ -110,7 +116,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller
|
|||
/// </summary>
|
||||
public IEnumerable<Process> GetSimilarProcesses(string processPath)
|
||||
{
|
||||
return Process.GetProcesses().Where(p => !IsSystemProcess(p) && TryGetProcessFilename(p) == processPath);
|
||||
return Process.GetProcesses().Where(p => !IsSystemProcessOrFlowLauncher(p) && TryGetProcessFilename(p) == processPath);
|
||||
}
|
||||
|
||||
public void TryKill(PluginInitContext context, Process p)
|
||||
|
|
|
|||
Loading…
Reference in a new issue