zoukankan      html  css  js  c++  java
  • mutex 实现 只允许一个进程

      static class Program
        {
            [STAThread]
            static void Main()
            {
                bool createdNew=false;
                Mutex mutex = new Mutex(true, @"GlobalAirVoice", 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
  • 相关阅读:
    windows常规
    oracle常规操作
    idea使用
    java-maven
    java-rabbimq
    centos7 rabbitMq 安装教程
    Leetcode 332.重新安排行程
    Leetcode 334.递增的三元子序列
    Leetcode 331.验证二叉树的前序序列化
    Leetcode 330.按要求补齐数组
  • 原文地址:https://www.cnblogs.com/wdfrog/p/3996516.html
Copyright © 2011-2022 走看看