Jackett/src/Jackett.Tray/Program.cs

36 lines
1.2 KiB
C#
Raw Normal View History

2015-07-19 00:27:41 +00:00
using System;
using System.Collections.Generic;
using System.Diagnostics;
2015-07-19 00:27:41 +00:00
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
2015-07-19 13:33:27 +00:00
namespace JackettTray
2015-07-19 00:27:41 +00:00
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
2017-12-01 09:39:50 +00:00
var JacketTrayProcess = Process.GetCurrentProcess();
var runningProcesses = Process.GetProcesses();
var currentSessionID = Process.GetCurrentProcess().SessionId;
var sameAsThisSession = runningProcesses.Where(p => p.SessionId == currentSessionID);
2017-12-01 09:39:50 +00:00
var sameAsThisSessionJacketTray = sameAsThisSession.Where(p => p.ProcessName == JacketTrayProcess.ProcessName && p.Id != JacketTrayProcess.Id);
if (sameAsThisSessionJacketTray.Any())
{
MessageBox.Show("JackettTray is already running");
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
}
2015-07-19 00:27:41 +00:00
}
}
}