I'm making a class that creates a new instance of an already existing form every time "New" is called. I'm implementing this in a Class Library, the class library has a "WndClass" (Class) and a "MainWindow" (Form). The problem is I get the above error whenever I try to close the window by InsWindow.Close
Here's the code:
Public Class WndClass
Public Shared WindowCount As Integer
Private InsWindow As MainWindow
Public Sub New()
WindowCount += 1
InsWindow = New MainWindow
InsWindow.Show()
End Sub
'.... Some window manipulation functions
Protected Overrides Sub Finalize()
WindowCount -= 1
InsWindow.Close()
InsWindow.Dispose()
MyBase.Finalize()
End Sub
End Class
I'm fairly new to the language so I decided to go experimenting and coding random ideas that come to my mind.
EDIT: I've read up some similar but not necessarily the same problems, and some of them said delegates are what solved the issues, can someone explain how can I use it to solve this?