controlling class behavior

Posted on 2005-04-12
Last Modified: 2010-04-23
How can you make it so a class in instantiated only once at a time?
Question by:rodmjay
    LVL 9

    Expert Comment

    Hi rodmjay,

        Use the singleton pattern...

    LVL 9

    Accepted Solution

    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

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now