diff --git a/PrintBarCode/Startup.cs b/PrintBarCode/Startup.cs index 5399054..d1a87c3 100644 --- a/PrintBarCode/Startup.cs +++ b/PrintBarCode/Startup.cs @@ -12,6 +12,7 @@ using SlnMesnac.Extensions; using SlnMesnac.Generate; using SlnMesnac.TouchSocket; using SlnMesnac.Redis; +using System.Threading; #region << 版 本 注 释 >> /*-------------------------------------------------------------------- @@ -42,12 +43,22 @@ namespace PrintBarCode /// public class Startup { + + private System.Threading.Mutex? mutex = null; /// /// /// /// public Startup(IConfiguration configuration) { + bool ret; + mutex = new System.Threading.Mutex(true, System.Diagnostics.Process.GetCurrentProcess().ProcessName, out ret); + if (!ret) + { + MessageBox.Show("应用程序已开启,禁止重复运行"); + Environment.Exit(0); + } + Configuration = configuration; } diff --git a/ReadService/Startup.cs b/ReadService/Startup.cs index f9639fe..51b6f11 100644 --- a/ReadService/Startup.cs +++ b/ReadService/Startup.cs @@ -13,6 +13,7 @@ using SlnMesnac.Generate; using SlnMesnac.TouchSocket; using ReadService; using SlnMesnac.Redis; +using System.Threading; #region << 版 本 注 释 >> /*-------------------------------------------------------------------- @@ -43,12 +44,20 @@ namespace ConsoleApp /// public class Startup { + private System.Threading.Mutex? mutex = null; /// /// /// /// public Startup(IConfiguration configuration) { + bool ret; + mutex = new System.Threading.Mutex(true, System.Diagnostics.Process.GetCurrentProcess().ProcessName, out ret); + if (!ret) + { + Console.WriteLine("应用程序已开启,禁止重复运行"); + Environment.Exit(0); + } Configuration = configuration; } diff --git a/SlnMesnac.WPF/Page/AgvAndTaskMonitorPage.xaml b/SlnMesnac.WPF/Page/AgvAndTaskMonitorPage.xaml index 6fddac2..eefede7 100644 --- a/SlnMesnac.WPF/Page/AgvAndTaskMonitorPage.xaml +++ b/SlnMesnac.WPF/Page/AgvAndTaskMonitorPage.xaml @@ -40,7 +40,7 @@