1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-28 09:15:46 +02:00
TweetDuck/Core/Utils/BrowserProcesses.cs
2017-06-30 23:53:36 +02:00

27 lines
811 B
C#

using System.Collections.Generic;
using System.Diagnostics;
using CefSharp;
namespace TweetDuck.Core.Utils{
static class BrowserProcesses{
private static readonly Dictionary<int, int> PIDs = new Dictionary<int, int>();
public static void Link(int identifier, int pid){
PIDs[identifier] = pid;
}
public static void Forget(int identifier){
PIDs.Remove(identifier);
}
public static Process FindProcess(IBrowser browser){
if (PIDs.TryGetValue(browser.Identifier, out int pid) && WindowsUtils.IsChildProcess(pid)){ // child process is checked in two places for safety
return Process.GetProcessById(pid);
}
else{
return null;
}
}
}
}