• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 241
  • Last Modified:

controlling class behavior

How can you make it so a class in instantiated only once at a time?
0
rodmjay
Asked:
rodmjay
1 Solution
 
cyberdevil67Commented:
Hi rodmjay,

    Use the singleton pattern...

Cheers!
0
 
checooCommented:
Public Class SingleInstance
    Shared myInstance As SingleInstance

    Private Sub New()

    End Sub

    Public Shared Function returnSingleInstance() As SingleInstance
        If myInstance Is Nothing Then
            myInstance = New SingleInstance
        End If
        Return myInstance
    End Function
End Class
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now