zoukankan      html  css  js  c++  java
  • 简单的只运行一个程序实例[原创]

     1using System;
     2using System.Collections.Generic;
     3using System.Windows.Forms;
     4using BOM.NewUI;
     5using System.Threading;
     6
     7namespace NewUI
     8{
     9    static class Program
    10    {
    11        /// <summary>
    12        /// 应用程序的主入口点。
    13        /// </summary>

    14        [STAThread]
    15        static void Main()
    16        {
    17            try
    18            {
    19                //声明互斥体。   
    20                Mutex mutex = new Mutex(false"ThisShouldOnlyRunOnce");
    21                //判断互斥体是否使用中。   
    22                bool running = !mutex.WaitOne(0false);
    23                if (!running)
    24                {
    25                    log4net.Config.XmlConfigurator.Configure();
    26                    Application.EnableVisualStyles();
    27                    Application.SetCompatibleTextRenderingDefault(false);
    28                    Thread.CurrentThread.Name = "GUI Main Thread";
    29                    Application.Run(new MainContext());
    30                }

    31            }

    32            catch (Exception ex)
    33            {
    34                MessageBox.Show(ex.ToString());
    35                log4net.LogManager.GetLogger("Main Thread").Error("error:", ex);
    36
    37            }

    38         }

    39
    40
    41    }

    42}
  • 相关阅读:
    jquery利用event.which方法获取键盘输入值的代码
    C#计算某个时间距离当前日期的天数
    C#.net 货币格式转换
    用批处理来重启IIS的应用程序池
    C# .net 如何根据访问者IP获取所在地区
    C# 根据IP查询地址归属地
    windows Server 2008 IIS7 503错误解决方案
    技术选型
    bootstrap bable 自动换行问题
    .net 部署IIS 在服务器无法杀掉EXCEL进程
  • 原文地址:https://www.cnblogs.com/winnxm/p/1072259.html
Copyright © 2011-2022 走看看