From 0fc26f7f012fb8c23880c92ccd30eed8b31c84c4 Mon Sep 17 00:00:00 2001 From: DucDangAnh Date: Mon, 6 Jul 2020 15:05:24 +0700 Subject: [PATCH] Util - UpdateImage and UpdateLabel check isDisposed --- AIParkingApplication/Util.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/AIParkingApplication/Util.cs b/AIParkingApplication/Util.cs index 1db17c6..1b350ae 100644 --- a/AIParkingApplication/Util.cs +++ b/AIParkingApplication/Util.cs @@ -80,6 +80,11 @@ namespace AIParkingApplication public static void UpdateImage(this PictureBox pictureBox, Bitmap image) { + if (pictureBox.IsDisposed) + { + return; + } + pictureBox.Invoke(new Action(() => { pictureBox.Image?.Dispose(); @@ -89,6 +94,11 @@ namespace AIParkingApplication public static void UpdateLabel(this Label label, string text, Color backColor, Color foreColor) { + if (label.IsDisposed) + { + return; + } + label.Invoke(new Action(() => { label.Text = text; @@ -99,6 +109,11 @@ namespace AIParkingApplication public static void UpdateLabel(this Label label, string text, Color backColor) { + if (label.IsDisposed) + { + return; + } + label.Invoke(new Action(() => { label.Text = text; @@ -108,6 +123,11 @@ namespace AIParkingApplication public static void UpdateLabel(this Label label, string text) { + if (label.IsDisposed) + { + return; + } + label.Invoke(new Action(() => { label.Text = text;