From c504567c4147298f5f2fcf02915f0b5b8945fd88 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Tue, 16 Jan 2024 16:28:15 +0100 Subject: [PATCH] Fix Init --- EnvelopeGenerator.Form/frmSplashScreen.vb | 52 ++++++++++++----------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/EnvelopeGenerator.Form/frmSplashScreen.vb b/EnvelopeGenerator.Form/frmSplashScreen.vb index 9bc19d66..bfaeb7da 100644 --- a/EnvelopeGenerator.Form/frmSplashScreen.vb +++ b/EnvelopeGenerator.Form/frmSplashScreen.vb @@ -106,37 +106,41 @@ Public Class frmSplashScreen End Sub Private Sub Worker_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles Worker.RunWorkerCompleted - If e.Error IsNot Nothing Then - Logger.Error(e.Error) - MsgBox("Fehler beim Initialisieren: " & e.Error.Message & vbNewLine & vbNewLine & e.Error.StackTrace, MsgBoxStyle.Critical, Text) - Application.Exit() - End If + Try + If e.Error IsNot Nothing Then + Throw e.Error + End If - Dim oState As State = DirectCast(e.Result, State) + Dim oState As State = DirectCast(e.Result, State) - Dim oCultureInfo As CultureInfo - oCultureInfo = New CultureInfo(oState.user.Language) - Thread.CurrentThread.CurrentCulture = oCultureInfo - Thread.CurrentThread.CurrentUICulture = oCultureInfo - CultureInfo.DefaultThreadCurrentCulture = oCultureInfo - CultureInfo.DefaultThreadCurrentUICulture = oCultureInfo + Dim oCultureInfo As CultureInfo + oCultureInfo = New CultureInfo(oState.User.Language) + Thread.CurrentThread.CurrentCulture = oCultureInfo + Thread.CurrentThread.CurrentUICulture = oCultureInfo + CultureInfo.DefaultThreadCurrentCulture = oCultureInfo + CultureInfo.DefaultThreadCurrentUICulture = oCultureInfo - If oState.User.HasAccess = False Then - Throw New ApplicationException("User is not activated for this module. Please contact your administrator. Application will close!") - End If + If oState.User.HasAccess = False Then + Throw New ApplicationException("User is not activated for this module. Please contact your administrator. Application will close!") + End If - If Not String.IsNullOrEmpty(oState.DbConfig.ExternalProgramName) Then - Text = oState.DbConfig.ExternalProgramName - End If + If Not String.IsNullOrEmpty(oState.DbConfig.ExternalProgramName) Then + Text = oState.DbConfig.ExternalProgramName + End If - ' Hide splashscreen - Hide() + ' Hide splashscreen + Hide() - Dim oForm As New frmMain(oState) - oForm.ShowDialog() + Dim oForm As New frmMain(oState) + oForm.ShowDialog() - ' Close this form after frmMain is closed - Close() + ' Close this form after frmMain is closed + Close() + Catch ex As Exception + Logger.Error(ex) + MsgBox("Fehler beim Initialisieren: " & ex.Message & vbNewLine & vbNewLine & ex.StackTrace, MsgBoxStyle.Critical, Text) + Application.Exit() + End Try End Sub