From da843919c9580cf07f8dcc25bd483d340f958df0 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sun, 13 May 2018 23:52:41 -0700 Subject: [PATCH] Use invoke so that we run code on the UI thread (no idea how this was working before) --- WindowsFormsSample/WindowsFormsSample/ChatForm.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/WindowsFormsSample/WindowsFormsSample/ChatForm.cs b/WindowsFormsSample/WindowsFormsSample/ChatForm.cs index 68e7ccc..5bcd3af 100644 --- a/WindowsFormsSample/WindowsFormsSample/ChatForm.cs +++ b/WindowsFormsSample/WindowsFormsSample/ChatForm.cs @@ -103,7 +103,12 @@ namespace WindowsFormsSample private void Log(Color color, string message) { - messagesList.Items.Add(new LogMessage(color, message)); + Action callback = () => + { + messagesList.Items.Add(new LogMessage(color, message)); + }; + + Invoke(callback); } private class LogMessage