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;