E
ECathell
I have a windows form that I only want one instance of. it currently is a child mdi form which may be changing as the project progresses. I have made it a singleton object by making the Sub new constructor private then using this code to call it:
Private Shared m_instance As ShippingOrderSetupInterface
Public Shared Function getInstance() As ShippingOrderSetupInterface
If m_instance Is Nothing Then
m_instance = New ShippingOrderSetupInterface
End If
m_instance.WindowState = FormWindowState.Maximized
Return m_instance
End Function
It works great. However, when I close the window, then try and reopen it later, i get an disposed object exception. How do I get around this? I have tried adding me.dispose after me.close. If I simply hide the window, it will work I suppose, but I am curious about the proper way to do it.
Private Shared m_instance As ShippingOrderSetupInterface
Public Shared Function getInstance() As ShippingOrderSetupInterface
If m_instance Is Nothing Then
m_instance = New ShippingOrderSetupInterface
End If
m_instance.WindowState = FormWindowState.Maximized
Return m_instance
End Function
It works great. However, when I close the window, then try and reopen it later, i get an disposed object exception. How do I get around this? I have tried adding me.dispose after me.close. If I simply hide the window, it will work I suppose, but I am curious about the proper way to do it.