From 29a5a258eadf1e7dc4c16056bea29ddde3026981 Mon Sep 17 00:00:00 2001 From: MaxXor Date: Mon, 6 Apr 2015 20:33:00 +0200 Subject: [PATCH] Fixed another cross threading bug --- Server/Core/Commands/CommandHandler.cs | 62 +++++++++++++------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/Server/Core/Commands/CommandHandler.cs b/Server/Core/Commands/CommandHandler.cs index a45a6443..61a3001d 100644 --- a/Server/Core/Commands/CommandHandler.cs +++ b/Server/Core/Commands/CommandHandler.cs @@ -1,11 +1,10 @@ using System; using System.Drawing; using System.IO; -using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; +using xServer.Core.Extensions; using xServer.Core.Helper; -using xServer.Core.Misc; using xServer.Core.Packets.ClientPackets; using xServer.Forms; using xServer.Settings; @@ -68,43 +67,42 @@ private static void ShowPopup(Client c) FrmMain.Instance.nIcon.ShowBalloonTip(30, string.Format("Client connected from {0}!", c.Value.Country), string.Format("IP Address: {0}\nOperating System: {1}", c.EndPoint.Address.ToString(), c.Value.OperatingSystem), ToolTipIcon.Info); } - public static void HandleStatus(Client client, Status packet) - { - new Thread(() => - { - FrmMain.Instance.Invoke((MethodInvoker) delegate - { - foreach (ListViewItem lvi in FrmMain.Instance.lstClients.Items) - { - Client c = (Client) lvi.Tag; - if (client == c) - { - lvi.SubItems[3].Text = packet.Message; - break; - } - } - }); - - }).Start(); - } - - public static void HandleUserStatus(Client client, UserStatus packet) + public static void HandleStatus(Client client, Status packet) { new Thread(() => { - foreach (ListViewItem lvi in FrmMain.Instance.lstClients.Items) + FrmMain.Instance.Invoke((MethodInvoker) delegate { - Client c = (Client)lvi.Tag; - if (client == c) + foreach (ListViewItem lvi in FrmMain.Instance.lstClients.Items) { - FrmMain.Instance.Invoke((MethodInvoker)delegate + Client c = (Client) lvi.Tag; + if (client == c) + { + lvi.SubItems[3].Text = packet.Message; + break; + } + } + }); + + }).Start(); + } + + public static void HandleUserStatus(Client client, UserStatus packet) + { + new Thread(() => + { + FrmMain.Instance.Invoke((MethodInvoker)delegate + { + foreach (ListViewItem lvi in FrmMain.Instance.lstClients.Items) + { + Client c = (Client)lvi.Tag; + if (client == c) { lvi.SubItems[4].Text = packet.Message; - }); - break; + break; + } } - } - + }); }).Start(); } @@ -414,7 +412,7 @@ public static void HandleGetSystemInfoResponse(Client client, GetSystemInfoRespo } }); - ListViewExtensions.autosizeColumns(client.Value.FrmSi.lstSystem); + ListViewExtensions.AutosizeColumns(client.Value.FrmSi.lstSystem); } catch { }