Fixed another cross threading bug

This commit is contained in:
MaxXor 2015-04-06 20:33:00 +02:00
parent aacd1e0f33
commit 29a5a258ea
1 changed files with 30 additions and 32 deletions

View File

@ -1,11 +1,10 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using xServer.Core.Extensions;
using xServer.Core.Helper; using xServer.Core.Helper;
using xServer.Core.Misc;
using xServer.Core.Packets.ClientPackets; using xServer.Core.Packets.ClientPackets;
using xServer.Forms; using xServer.Forms;
using xServer.Settings; 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); 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) 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)
{ {
new Thread(() => new Thread(() =>
{ {
foreach (ListViewItem lvi in FrmMain.Instance.lstClients.Items) FrmMain.Instance.Invoke((MethodInvoker) delegate
{ {
Client c = (Client)lvi.Tag; foreach (ListViewItem lvi in FrmMain.Instance.lstClients.Items)
if (client == c)
{ {
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; lvi.SubItems[4].Text = packet.Message;
}); break;
break; }
} }
} });
}).Start(); }).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 catch
{ } { }