Add Heartbeat Function to Service, Add Timer to ClientSuite Service Startup check

This commit is contained in:
Jonathan Jenne
2019-02-18 17:06:41 +01:00
parent bc7605bdcf
commit 4229682da0
24 changed files with 259 additions and 85 deletions

View File

@@ -49,6 +49,12 @@ Public NotInheritable Class frmSplash
End Function
#Region "Worker"
Private Enum WorkerResult
AllGood
ServiceOffline
End Enum
Private Sub StartWorker()
AddHandler _Worker.DoWork, AddressOf bw_DoWork
AddHandler _Worker.ProgressChanged, AddressOf bw_ProgressChanged
@@ -58,17 +64,25 @@ Public NotInheritable Class frmSplash
_Worker.RunWorkerAsync()
End Sub
Private Sub bw_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs)
Private Async Sub bw_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs)
Dim oService As New ClassService(My.LogConfig)
_Worker.ReportProgress(SetProgress(1), "Connecting to service..")
Dim oChannelFactory As ChannelFactory(Of IEDMServiceChannel)
Dim oChannel As IEDMServiceChannel
Dim oConnectionSuccessful = False
oChannelFactory = oService.GetChannelFactory()
oChannel = oChannelFactory.CreateChannel()
e.Result = WorkerResult.AllGood
_ChannelFactory = oService.GetChannelFactory()
_Channel = _ChannelFactory.CreateChannel()
'Dim oServiceOnline = Await oService.TestConnectionAsync()
Dim oServiceState = oService.TestConnection()
If oServiceState <> ClassService.ConnectionTestResult.Successful Then
e.Result = WorkerResult.ServiceOffline
Return
End If
Thread.Sleep(SLEEP_TIME)
@@ -92,11 +106,25 @@ Public NotInheritable Class frmSplash
Private Sub bw_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs)
' Bei Fehler MsgBox anzeigen und Programm beenden
If e.Error IsNot Nothing Then
'ClassLogger.Add("Unexpected error in Initializing application....")
MsgBox(e.Error.Message, MsgBoxStyle.Critical, "Critical Error")
MsgBox(e.Error.Message, MsgBoxStyle.Critical, "Unhandled Error")
Application.Exit()
ElseIf e.Result <> WorkerResult.AllGood Then
Dim oErrorMessage
Select Case e.Result
Case WorkerResult.ServiceOffline
oErrorMessage = "Service is offline!"
Case Else
oErrorMessage = "Unknown Error"
End Select
MsgBox($"Application could not be started{vbNewLine}Reason: {oErrorMessage}", MsgBoxStyle.Critical, "Critical Error")
Application.Exit()
End If
My.ChannelFactory = _ChannelFactory
My.Channel = _Channel
' Wenn kein Fehler, Splashscreen schließen
Me.Close()
End Sub