private void buttonInterChat_Click(object sender, EventArgs e) { var userName = textAccountName.Text.Trim(); if (string.IsNullOrWhiteSpace(userName)) { ShowError("Invalid username"); textAccountName.SelectAll(); textAccountName.Focus(); return; } if (_interChatForm != null) { _interChatForm.Dispose(); _interChatForm = null; GC.Collect(); } // 첫 패킷의 유실을 막기 위해 일단 패킷 핸들러부터 먼저 만든다. _interChatForm = new FormInterChat(_session, userName); _interChatForm.Closed += (obj, args) => Close(); _session.Send(new InterChatLoginMsg { Name = userName }); }