void shard_ReceivedLobbyChatMessage(object sender, LobbyChatEventArgs args) { string newLine; if (args.Sender == null) { newLine ="You: " + args.Message; } else { newLine = args.Sender + ": " + args.Message; } this.BeginInvoke(new ParameterizedThreadStart(AddMessage), (object)newLine); }
void shard_ReceivedGameChatMessage(object sender, LobbyChatEventArgs args) { if (this.InvokeRequired) { BeginInvoke(new LobbyChatEventHandler(shard_ReceivedGameChatMessage), sender, args); return; } string newLine; if (args.Sender == null) { newLine = "You: " + args.Message; } else { newLine = args.Sender + ": " + args.Message; } textGameMessages.Text = textGameMessages.Text + Environment.NewLine + (string)newLine; textGameMessages.SelectionStart = textGameMessages.Text.Length; textGameMessages.ScrollToCaret(); }