Namespace UTSModule.Test.StatusMonitor

    Public Class DatabaseStatusChangedEventArgs
        Inherits EventArgs

        Sub New(dbStatus As DatabaseStatusMonitor.DatabaseSyncStatusEnum)
            Status = dbStatus
        End Sub

        Public Property Status As DatabaseStatusMonitor.DatabaseSyncStatusEnum

    End Class


    Public Class DatabaseStatusMonitor

        Enum DatabaseSyncStatusEnum
            Completed
            Completing
            UnCompleted
        End Enum


        Public Delegate Sub DatabaseSyncStatusChangedEventHandler(sender As Object, e As DatabaseStatusChangedEventArgs)

        ''' <summary>
        ''' 在数据库同步状态更改时发生
        ''' </summary>
        Public Shared Event DatabaseSyncStatusChanged As DatabaseSyncStatusChangedEventHandler

        Private Shared _dbSyncStatus As DatabaseSyncStatusEnum = DatabaseSyncStatusEnum.Completed

        ''' <summary>
        ''' 数据库同步状态
        ''' </summary>
        ''' <returns></returns>
        Public Shared Property DatabaseSyncStatus() As DatabaseSyncStatusEnum
            Get
                Return _dbSyncStatus
            End Get
            Set(value As DatabaseSyncStatusEnum)
                If _dbSyncStatus = value Then Return
                _dbSyncStatus = value
                RaiseEvent DatabaseSyncStatusChanged(Nothing, New DatabaseStatusChangedEventArgs(_dbSyncStatus))
            End Set
        End Property
    End Class

End Namespace