码迷,mamicode.com
首页 > 其他好文 > 详细

mutex 实现 只允许一个进程

时间:2014-09-27 18:54:00      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   io   os   ar   for   

 

bubuko.com,布布扣
  static class Program
    {
        [STAThread]
        static void Main()
        {
            bool createdNew=false;
            Mutex mutex = new Mutex(true, @"Global\AirVoice", out createdNew);
            try
            {

                if (createdNew)
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);

                    LoginForm loginForm = new LoginForm();
                    if (loginForm.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }

                    IMultimediaManager multimediaManager = MultimediaManagerFactory.GetSingleton();
                    multimediaManager.CameraDeviceIndex = 0;
                    multimediaManager.MicrophoneDeviceIndex = 0;
                    multimediaManager.AutoAdjustCameraEncodeQuality = false;
                    multimediaManager.CameraEncodeQuality = 0;

                    multimediaManager.ChannelMode = ChannelMode.P2PChannelFirst;
                    multimediaManager.Initialize(loginForm.CurrentUserID, loginForm.CurrentPwd, ConfigurationManager.AppSettings["ServerIP"], int.Parse(ConfigurationManager.AppSettings["ServerPort"]));

                    multimediaManager.AllowControlDesktop = false;
                    multimediaManager.OutputDesktop = false;



                    MainForm mainForm = new MainForm();
                    mainForm.Initialize(multimediaManager, loginForm.CurrentUserID);

                    Application.Run(mainForm);
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message + "," + ee.StackTrace);
            }finally
            {
                mutex.ReleaseMutex();
                
            }
        }
    }
View Code

 

mutex 实现 只允许一个进程

标签:des   style   blog   http   color   io   os   ar   for   

原文地址:http://www.cnblogs.com/wdfrog/p/3996516.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!