diff --git a/Camera_connect/Main.Designer.cs b/Camera_connect/Main.Designer.cs index bf57432..39f26bb 100644 --- a/Camera_connect/Main.Designer.cs +++ b/Camera_connect/Main.Designer.cs @@ -162,6 +162,7 @@ Controls.Add(Bt_connect); Name = "Main"; Text = "Form1"; + FormClosed += Form1_FormClosed; ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); ResumeLayout(false); PerformLayout(); diff --git a/Camera_connect/Main.cs b/Camera_connect/Main.cs index f619c0e..743b781 100644 --- a/Camera_connect/Main.cs +++ b/Camera_connect/Main.cs @@ -308,5 +308,12 @@ namespace Camera_connect } } + + private void Form1_FormClosed(object sender, FormClosedEventArgs e) + { + + Basler.DestroyCamera(); + pictureBox1.Image?.Dispose(); + } } }