App.xaml.cs 846 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. namespace AIRS
  9. {
  10. /// <summary>
  11. /// App.xaml 的交互逻辑
  12. /// </summary>
  13. public partial class App : Application
  14. {
  15. System.Threading.Mutex mutex;
  16. public App()
  17. {
  18. this.Startup += new StartupEventHandler(App_Startup);
  19. }
  20. void App_Startup(object sender, StartupEventArgs e)
  21. {
  22. bool ret;
  23. mutex = new System.Threading.Mutex(true, "AIRS", out ret);
  24. if (!ret)
  25. {
  26. MessageBox.Show("已有一个程序实例正在运行","提示",MessageBoxButton.OK,MessageBoxImage.Error);
  27. Environment.Exit(0);
  28. }
  29. }
  30. }
  31. }