Handle một lỗi Thread chạy trước khi Control được tạo dẫn đến lỗi

This commit is contained in:
Le Chau 2020-06-26 16:55:14 +07:00
parent 30f5f14ee7
commit 5d7dcd63da

View File

@ -22,6 +22,8 @@ namespace AIParkingApplication
private void UpdateStatus() private void UpdateStatus()
{ {
while (true) while (true)
{
if (IsHandleCreated)
{ {
lblDateTime.Invoke(new Action(() => lblDateTime.Invoke(new Action(() =>
{ {
@ -43,6 +45,7 @@ namespace AIParkingApplication
lblPingTimeServer.BackColor = pingResult.BackColor; lblPingTimeServer.BackColor = pingResult.BackColor;
lblPingTimeServer.ForeColor = pingResult.ForceColor; lblPingTimeServer.ForeColor = pingResult.ForceColor;
})); }));
}
Thread.Sleep(1000); Thread.Sleep(1000);
} }
} }