From 46bd17c4fa47923d403a2064eb293c93688051a6 Mon Sep 17 00:00:00 2001 From: Abdullah Saleem Date: Mon, 6 Apr 2015 22:12:56 +0500 Subject: [PATCH] Cross-Thread exception handled Cross-Thread exception on Uninstall --- Server/Core/Commands/CommandHandler.cs | 39 +++++++++++++------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/Server/Core/Commands/CommandHandler.cs b/Server/Core/Commands/CommandHandler.cs index a42dd2f6..ea4dd20c 100644 --- a/Server/Core/Commands/CommandHandler.cs +++ b/Server/Core/Commands/CommandHandler.cs @@ -1,6 +1,7 @@ using System; using System.Drawing; using System.IO; +using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; using xServer.Core.Helper; @@ -68,27 +69,27 @@ 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(() => - { - foreach (ListViewItem lvi in FrmMain.Instance.lstClients.Items) - { - Client c = (Client)lvi.Tag; - if (client == c) - { - FrmMain.Instance.Invoke((MethodInvoker)delegate - { - lvi.SubItems[3].Text = packet.Message; - }); - break; - } - } + 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(); - } + }).Start(); + } - public static void HandleUserStatus(Client client, UserStatus packet) + public static void HandleUserStatus(Client client, UserStatus packet) { new Thread(() => {