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}
  • 相关阅读:
    git的优秀教程
    线性表的顺序存储结构和链式存储结构的比较
    python3基础知识学习记录
    thinkPHP为什么设置一个单入口文件?
    2017年读过的专业书
    DFS(深度优先搜索)模板
    HDOJ2553-N皇后问题(DFS)
    POJ(2784)Buy or Build
    并查集 分类: 并查集 2015-07-09 16:32 0人阅读 评论(0) 收藏
    Number of Containers(数学) 分类: 数学 2015-07-07 23:42 1人阅读 评论(0) 收藏
  • 原文地址:https://www.cnblogs.com/winnxm/p/1072259.html
Copyright © 2011-2022 走看看