i have made a userControl library .. and it contains NetworkStream, StreamReader, FileStream
So do i have to Dispose them all when the form that has this userControl closes ??
I mean There’s no such Form1_FormClosing(object sender,FormClosingEventArgs e) in a userControl so when should i dispose those streams?
Does userControl1.Dispose() take care of that?
thanks in advance 🙂
UserControl.Dispose()disposes the components in it’sControlscollection, but nothing more.You can handle the
UserControl.Disposedevent, or you can properly implement the Dispose pattern.For C# user controls,
protected override void Dispose(bool disposing)is auto-created inUserControl1.Designer.cs. You can amend it to: