コード例 #1
0
        private void InLobby_FormClosing(Object sender, FormClosingEventArgs e)
        {
            DialogResult result = MessageBox.Show(isHost ? "是否关闭房间?\n这会导致您房间中的所有人视频中断。" : "是否退出房间?", "Info", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            if (result == DialogResult.OK)
            {
                Global.IsInLobby = false;
                try {
                    if (browserContoller != null)
                    {
                        browserContoller.Close();
                    }
                    if (syncWorker != null)
                    {
                        syncWorker.Stop();
                    }
                    bgw_viewers_syncer.CancelAsync();
                    if (isHost)
                    {
                        borrower.Return();
                    }
                    else
                    {
                        borrower.Leave(Global.MyName);
                    }
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                e.Cancel = true;
            }
        }