The SplashScreen ist a WPF Form with just Code behind, no VMMW, for testing. So i can adress the Progress Bar Value directly.
This is my Example Code:
Public Class SplashScreen
Public Sub New()
InitializeComponent()
End Sub
Private Async Function LoadClassesTask() As Task
Dim progress = New Progress(Of Integer)(Sub(percent)
ProgressBar.Value = percent
End Sub)
Await Task.Factory.StartNew(FDoWork(progress), CancellationToken.None, TaskCreationOptions.None, TaskScheduler.FromCurrentSynchronizationContext())
End Function
Public Shared Function FDoWork(progress As IProgress(Of Integer)) As Action
Dim i As Integer = 0
'Create New Instances of Page-Classes
customerpage = New Pg_Customer
i += intLoadingProgress ' -> Global Integer = 9
If progress IsNot Nothing Then progress.Report(i)
pdfpage = New Pg_PDF_View
i += intLoadingProgress
If progress IsNot Nothing Then progress.Report(i)
editorpage = New Pg_Editor
i += intLoadingProgress
If progress IsNot Nothing Then progress.Report(i)
accpage = New Pg_Accounting
i += intLoadingProgress
If progress IsNot Nothing Then progress.Report(i)
accselectpage = New Pg_AccountingSelect
i += intLoadingProgress
If progress IsNot Nothing Then progress.Report(i)
tyreprotokollpage = New Pg_Tyreprotokoll
i += intLoadingProgress
If progress IsNot Nothing Then progress.Report(i)
dbselectpage = New Pg_DatabaseSelect
i += intLoadingProgress
If progress IsNot Nothing Then progress.Report(i)
dbRG = New Pg_Database_RG
i += intLoadingProgress
If progress IsNot Nothing Then progress.Report(i)
dbAP = New Pg_Database_AP
i += intLoadingProgress
If progress IsNot Nothing Then progress.Report(i)
dbMP = New Pg_Database_MP
i += intLoadingProgress
If progress IsNot Nothing Then progress.Report(i)
dbSP = New Pg_Database_SP
i += intLoadingProgress
If progress IsNot Nothing Then progress.Report(i)
pganalyzer = New Pg_DocAnalyzer
i += intLoadingProgress
If progress IsNot Nothing Then progress.Report(i)
dashboardpage = New Pg_Dashboard
i += intLoadingProgress
If progress IsNot Nothing Then progress.Report(i)
delivernotespage = New Pg_DeliveryNotes
i += intLoadingProgress
If progress IsNot Nothing Then progress.Report(i)
dbCar = New Pg_Database_Car
i += intLoadingProgress
If progress IsNot Nothing Then progress.Report(i)
Return Nothing
End Function
Private Sub Btn_Start_Click(sender As Object, e As RoutedEventArgs) Handles Btn_Start.Click
LoadClassesTask()
End Sub
End Class
It Runs now like this, but still the Page freezes and Progress Bar gets updated after all Classes are instantiated.
I guess im making a very stupid mistake somewhere but i just cant find it.