mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-08-17 00:31:42 +02:00
.github
.idea
Application
Browser
Configuration
Controls
Dialogs
Management
Plugins
Properties
Resources
Updates
Utils
bld
lib
subprocess
Properties
Program.cs
TweetDuck.Browser.csproj
packages.config
video
.gitattributes
.gitignore
LICENSE.md
Program.cs
README.md
Reporter.cs
TweetDuck.csproj
TweetDuck.sln
TweetDuck.sln.DotSettings
Version.cs
app.config
packages.config
46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.Threading.Tasks;
|
|
using CefSharp.BrowserSubprocess;
|
|
|
|
namespace TweetDuck.Browser {
|
|
static class Program {
|
|
private static int Main(string[] args) {
|
|
SubProcess.EnableHighDPISupport();
|
|
|
|
string FindArg(string key) {
|
|
return Array.Find(args, arg => arg.StartsWith(key, StringComparison.OrdinalIgnoreCase)).Substring(key.Length);
|
|
}
|
|
|
|
const string typePrefix = "--type=";
|
|
const string parentIdPrefix = "--host-process-id=";
|
|
|
|
if (!int.TryParse(FindArg(parentIdPrefix), out int parentId)) {
|
|
return 0;
|
|
}
|
|
|
|
Task.Factory.StartNew(() => KillWhenHung(parentId), TaskCreationOptions.LongRunning);
|
|
|
|
if (FindArg(typePrefix) == "renderer") {
|
|
using SubProcess subProcess = new SubProcess(null, args);
|
|
return subProcess.Run();
|
|
}
|
|
else {
|
|
return SubProcess.ExecuteProcess(args);
|
|
}
|
|
}
|
|
|
|
private static async void KillWhenHung(int parentId) {
|
|
try {
|
|
using Process process = Process.GetProcessById(parentId);
|
|
process.WaitForExit();
|
|
} catch {
|
|
// ded
|
|
}
|
|
|
|
await Task.Delay(10000);
|
|
Environment.Exit(0);
|
|
}
|
|
}
|
|
}
|