首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

c#同1时刻仅运行一个实例

2012-09-03 
c#同一时刻仅运行一个实例using Systemusing System.Collections.Genericusing System.Windows.Formsus

c#同一时刻仅运行一个实例

using System;using System.Collections.Generic;using System.Windows.Forms;using System.Reflection;using System.Threading;namespace SingelProsess{    static class Program    {        /// <summary>        /// 应用程序的主入口点。        /// </summary>        [STAThread]        static void Main()        {            Application.EnableVisualStyles();            Application.SetCompatibleTextRenderingDefault(false);            bool first = false;            string name = Assembly.GetEntryAssembly().FullName;            using (Mutex muten = new Mutex(false, name, out first))            {                if (first)                {                    Application.Run(new Form1());                }                else                {                    MessageBox.Show("实例已经运行");                }            }       }    }}

?

热点排行