Hello Experts,
I have a WPF window that loads a canvas.
So I am trying to show a window before the canvas loads just like progress bar.
No I did this is using Threading and Background process.
I am newbie to these concepts.
I am successful in making it work as said above.
On my MainWindow.xaml.vb
Private Sub ShowBG()
MyProgresswin.Title = "Loading"
MyProgresswin.Show()
worker.RunWorkerAsync()
End Sub
Private Sub worker_Dowork(sender As Object, e As DoWorkEventArgs) Handles worker.DoWork
Application.Current.Dispatcher.Invoke(Function()
CreateCanvas()
End Function)
End Sub
Private Sub worker_ProgressChanged(Sender As Object, e As ProgressChangedEventArgs) Handles worker.ProgressChanged
End Sub
Private Sub worker_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles worker.RunWorkerCompleted
MyProgresswin.Close()
End Sub
On the other hand I have another window with nake Progresswin and it contains below methods.
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
ShowProgress()
End Sub
Public Property ProgressText() As String
Get
Return lbl.Content
End Get
Set(value As String)
lbl.Content = value
End Set
End Property
Private Sub ShowProgress()
Try
bi.IsBusy = True
bi.BusyContent = "Loading..."
'AddHandler worker.RunWorkerCompleted, Sub(o, a)
' bi.IsBusy = False
' End Sub
worker.RunWorkerAsync()
Catch ex As Exception
MessageBox.Show(ex.ToString() + "ShorProgress_Progresswin")
End Try
End Sub
Sub worker_DoWork(sender As Object, e As DoWorkEventArgs) Handles worker.DoWork
Try
AddHandler worker.DoWork, Sub(o, a)
For index As Integer = 1 To 10
Dispatcher.Invoke(New Action(Function()
bi.BusyContent = "Loop : " + index
End Function), Nothing)
Thread.Sleep(New TimeSpan(0, 0, 1))
Next
End Sub
Catch ex As Exception
MessageBox.Show(ex.ToString() + "Worker_Dowork_Progresswin")
End Try
End Sub
Private Sub worker_ProgressChanged(Sender As Object, e As ProgressChangedEventArgs) Handles worker.ProgressChanged
ProgressText = CType(e.UserState, String)
End Sub
What I have tried:
So I have put all the efforts in showing a window before the canvas loads. and closes the window after canvas is loaded.
I want the first window to show some gif image of loading image in it. But that part doesn't work
PS: After deleting the question I posted I have got to certain level for the issue so had to create a new question with current issue