vb.net: is threaded form completely loaded?
I use a BackgroundWorker to load a big form without halting the
functionailty of the main form, but when I try to show the subform too
early I get an Object not set to reference exception.
I've tried the RunWorkerCompleted event, and the Load event of the form,
disabling the controls to show the form until they are raised, but it
seems those methods are unaware if the loading of the resources is fully
completed. Because the form shouldn't be visible yet I cannot use the
Activated or Shown events.
Dim bg As New ComponentModel.BackgroundWorker
AddHandler bg.DoWork, AddressOf rtfload
AddHandler bg.RunWorkerCompleted, AddressOf rtfloaded
bg.RunWorkerAsync()
Private Sub rtfload()
ed = New rtf()
End Sub
Public Sub rtfloaded()
Try
ed.Text = "" '<-- object not set to reference
Catch ex As Exception
rtfloaded()
Finally
tools.Enabled = True
End Try
End Sub
No comments:
Post a Comment