<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Singleton pattern</Title>
      <Shortcut>Singletonpattern</Shortcut>
      <Description>Singleton pattern [VB.NET]</Description>
      <Author>Benoit Gauthier</Author>
      <HelpUrl>/PreviewSnippet.aspx?SnippetID=54629f4b-a5c5-4a3f-94b5-503684280c31</HelpUrl>
      <SnippetTypes>
        <SnippetType>SurroundsWith</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Code Language="VB"><![CDATA['
' This class implements the Singleton pattern
'
Public Class Singleton
    ' Constructor is private so we can not create it
    ' Must use getInstance that return one (1) instance of the object.
    Private Sub New()
    End Sub
    Private Shared m_oInstance As Singleton
    Public Shared Function getInstance() As Singleton
        SyncLock GetType(Singleton)
            If IsNothing(m_oInstance) Then
                m_oInstance = New Singleton
            End If
        End SyncLock
        Return m_oInstance
    End Function
End Class]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>