コード例 #1
0
        /// <summary>
        /// 开始结束的Label和Panel均绑定此事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lb_BeingOver_MouseClick(object sender, MouseEventArgs e)
        {
            Thread th = null;

            try
            {
                UpdateBeginButton(isBegin);
                if (!isBegin)
                {
                    //设置F2热键的ID为100,注册热键
                    //logger.Info("注册系统热键F2键。");
                    //HotKey.RegisterHotKey(Handle, 100, HotKey.KeyModifiers.None, Keys.F2);
                    isBegin = true;
                    Mic     = AddMicrophone();
                    //if (ddlAudioOut.Count > 0 && !string.IsNullOrEmpty(clientIP))
                    //{
                    //    Mic.settings.sourcename = clientIP;
                    //    Mic.settings.active = true;
                    //    Mic.settings.deviceout = ((ListItem)ddlAudioOut[0]).Value[0];
                    //    MicVolumeLevel = new SendVolumeLevel(Mic);
                    //    MicVolumeLevel.AudioMode = 0;
                    //    MicVolumeLevel.Enable();
                    //}
                    ChildThreadException  = null;
                    ChildThreadException += new ChildThreadExceptionHandler(Import_ChildThreadException);
                    th = new Thread(new System.Threading.ThreadStart(MicVolumeLevelEnable));
                    th.IsBackground = true;
                    th.Start();
                }
                else
                {
                    //logger.Info("取消注册系统热键F2键。");
                    //HotKey.UnregisterHotKey(Handle, 100);
                    isBegin = false;
                    if (MicVolumeLevel != null)
                    {
                        //断开语音传输
                        MicVolumeLevel.Disable();
                    }
                    if (th != null)
                    {
                        th.Abort();
                    }

                    speakTime.Stop();
                    sw.Stop();
                    sw.Reset();
                    logger.Info("结束指挥!!!计时器停止。");
                }
            }
            catch (SocketException)
            {
            }
            catch (Exception be)
            {
                logger.Error("指挥操作出现异常。Exception:{0}", be.Message);
            }
        }
コード例 #2
0
        /// <summary>
        /// 启动服务器线程
        /// </summary>
        private void StartServer()
        {
            //注册异常捕获事件,发生异常时调用ChildThreadExceptionHandle
            ChildThreadException += new ChildThreadExceptionHandler(ChildThreadExceptionHandle);

            Thread ListenThread = new Thread(ListenConnect)
            {
                Name         = "服务器监听线程",
                IsBackground = true
            };

            ListenThread.Start();
        }