mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-08-16 06:31:42 +02:00
Configuration
Core
Bridge
Controls
Handling
Notification
Other
Utils
BrowserCache.cs
BrowserProcesses.cs
BrowserUtils.cs
CommandLineArgs.cs
CommandLineArgsParser.cs
InjectedHTML.cs
NativeMethods.cs
TwoKeyDictionary.cs
WindowState.cs
WindowsUtils.cs
FormBrowser.Designer.cs
FormBrowser.cs
FormBrowser.resx
TrayIcon.Designer.cs
TrayIcon.cs
Plugins
Properties
Resources
Updates
bld
lib
subprocess
tests
.gitignore
LICENSE.md
Program.cs
README.md
Reporter.cs
TweetDuck.csproj
TweetDuck.sln
TweetDuck.sln.DotSettings
_postbuild.bat
packages.config
27 lines
811 B
C#
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;
|
|
}
|
|
}
|
|
}
|
|
}
|