mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-02 11:14:04 +00:00
[exe] single instance only
This commit is contained in:
parent
bba8c6fe4e
commit
fc8a324f41
1 changed files with 11 additions and 0 deletions
|
@ -8,6 +8,7 @@ using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
@ -35,6 +36,8 @@ namespace UptimeKuma {
|
||||||
|
|
||||||
public class UptimeKumaApplicationContext : ApplicationContext
|
public class UptimeKumaApplicationContext : ApplicationContext
|
||||||
{
|
{
|
||||||
|
private static Mutex mutex = null;
|
||||||
|
|
||||||
const string appName = "Uptime Kuma";
|
const string appName = "Uptime Kuma";
|
||||||
|
|
||||||
private NotifyIcon trayIcon;
|
private NotifyIcon trayIcon;
|
||||||
|
@ -48,6 +51,14 @@ namespace UptimeKuma {
|
||||||
|
|
||||||
|
|
||||||
public UptimeKumaApplicationContext() {
|
public UptimeKumaApplicationContext() {
|
||||||
|
|
||||||
|
// Single instance only
|
||||||
|
bool createdNew;
|
||||||
|
mutex = new Mutex(true, appName, out createdNew);
|
||||||
|
if (!createdNew) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var startingText = "Starting server...";
|
var startingText = "Starting server...";
|
||||||
trayIcon = new NotifyIcon();
|
trayIcon = new NotifyIcon();
|
||||||
trayIcon.Text = startingText;
|
trayIcon.Text = startingText;
|
||||||
|
|
Loading…
Reference in a new issue