判断窗体是否已运行 纵一苇之所如

static System.Threading.Mutex MyMutex;
        /// <summary>
        /// 判断程序是否已运行

        /// </summary>
        private static bool IsMyMutex()
        {
            bool IsExist;
            MyMutex = new System.Threading.Mutex(true, Application.ProductName, out  IsExist);
            if (IsExist)
            {
                return false;
            }
            else
            {
                return true;
            }
        }

调用:

 static void Main()
        {
            if (IsMyMutex()) //不允许同一机器同时启动多个
            {
                return;
            }

}

原文地址:https://www.cnblogs.com/panjinzhao/p/3107760.html