1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
void buttonRefresh(object sender, EventArgs e)
{
new Thread(RefreshData).Start();
}
void RefreshData()
{
Invoke(() => Cursor.Current = Cursors.WaitCursor);
try
{
using(ClientTcp client = new ClientTcp())
{
client.Connect(_serverScanIp, _serverScanPort);
client.sendTerminalId();
string text = (client.CallTraitement(comm.commConst.MSG_TraitItem)) ? "OK" : "";
Invoke(() => labelItem.Text = text);
text = (client.CallTraitement(comm.commConst.MSG_TraitSalesLine)) ? "OK" : "";
Invoke(() => labelSalesLines.Text = text);
text = (client.CallTraitement(comm.commConst.MSG_TraitSalesHeader)) ? "OK" : "";
Invoke(() => labelSalesHeaders.Text = text);
text = (client.CallTraitement(comm.commConst.MSG_TraitSalesPackagingDetail)) ? "OK" : "";
Invoke(() => labelSalesPackaging.Text = text);
text = (client.CallTraitement(comm.commConst.MSG_TraitCleanUp)) ? "OK" : "";
Invoke(() => labelCleanUp.Text = text);
client.DisConnect();
}
Invoke(() => labelTraitementTermine.Text = "TRAITEMENT TERMINE");
}
catch (Exception ex)
{
log.Log(ex);
Invoke(() => MessageBox.Show("(Server scan) : " + ex.Message));
}
finally
{
Invoke(() => Cursor.Current = Cursors.Default);
}
}
// Pour faciliter l'utilisation avec des expressions lambda
void Invoke(Action action)
{
Invoke((Delegate)action);
} |