根据GUID获取实例

Public Class PzscSingleHandler
    Private Sub New()

    End Sub

    Private Shared instanceList As New System.Collections.Generic.Dictionary(Of Guid, PzscSingleHandler)

    Private Shared obj As New Object()

    ''' <summary>
    ''' 根据项目GUID获取实例
    ''' </summary>
    ''' <param name="projGUID"></param>
    ''' <returns></returns>
    Public Shared Function GetInstance(ByVal projGUID As Guid) As PzscSingleHandler
        If projGUID = Guid.Empty Then
            Return Nothing
        End If
        SyncLock (obj)
            If Not instanceList.ContainsKey(projGUID) Then
                instanceList.Add(projGUID, New PzscSingleHandler())
            End If
            Return instanceList(projGUID)
        End SyncLock

    End Function

    Public Function test() As String
        Return ""
    End Function


End Class

 

posted @ 2019-08-01 11:17  看看我的眼神  阅读(763)  评论(0编辑  收藏  举报