Waiting form

  • Thread starter Thread starter nokia33948
  • Start date Start date
N

nokia33948

Hi there,
I am trying to write code for a waiting form. My intention is to
replace the hourglass cursor while updating the main form.

I have created the waiting form that contains an animated gif; the
main form should freeze, show the waiting form, and, after all the
updates, come up again with new values.

The code I wrote is this:

Private WaitingForm As frmWaiting
Private FormThatIsWaiting As Form
Private ms_oThread As System.Threading.Thread

....

Public Sub StartWaiting(ByVal StartForm As Form)

FormThatIsWaiting = StartForm

FormThatIsWaiting.SuspendLayout()
FormThatIsWaiting.Enabled = False

ms_oThread = New System.Threading.Thread(New
System.Threading.ThreadStart(AddressOf ThreadingJob))
ms_oThread.IsBackground = True
ms_oThread.Start()

End Sub

Private Sub ThreadingJob()
..
WaitingForm = New frmWaiting

WaitingForm.ShowDialog()

End Sub

Public Sub EndWaiting()

If Not WaitingForm Is Nothing Then
Dim mi As New MethodInvoker(AddressOf WaitingForm.Close)

WaitingForm.BeginInvoke(mi)

WaitingForm = Nothing
ms_oThread = Nothing

FormThatIsWaiting.Enabled = True
FormThatIsWaiting.ResumeLayout()
FormThatIsWaiting = Nothing

End If

End Sub

The main form calls the StartWaiting sub, makes the update, calls the
EndWaiting sub and shows the new values. It works fine, but I would
like to freeze the form instead of making it disabled. Is that
possible? Is there anyone who could give me any suggestion?

Thanks and regards,
D.
 
Hi there,
I am trying to write code for a waiting form. My intention is to
replace the hourglass cursor while updating the main form.

I have created the waiting form that contains an animated gif; the
main form should freeze, show the waiting form, and, after all the
updates, come up again with new values.

The code I wrote is this:

Private WaitingForm As frmWaiting
Private FormThatIsWaiting As Form
Private ms_oThread As System.Threading.Thread

...

Public Sub StartWaiting(ByVal StartForm As Form)

FormThatIsWaiting = StartForm

FormThatIsWaiting.SuspendLayout()
FormThatIsWaiting.Enabled = False

ms_oThread = New System.Threading.Thread(New
System.Threading.ThreadStart(AddressOf ThreadingJob))
ms_oThread.IsBackground = True
ms_oThread.Start()

End Sub

Private Sub ThreadingJob()
.
WaitingForm = New frmWaiting

WaitingForm.ShowDialog()

End Sub

Public Sub EndWaiting()

If Not WaitingForm Is Nothing Then
Dim mi As New MethodInvoker(AddressOf WaitingForm.Close)

WaitingForm.BeginInvoke(mi)

WaitingForm = Nothing
ms_oThread = Nothing

FormThatIsWaiting.Enabled = True
FormThatIsWaiting.ResumeLayout()
FormThatIsWaiting = Nothing

End If

End Sub

The main form calls the StartWaiting sub, makes the update, calls the
EndWaiting sub and shows the new values. It works fine, but I would
like to freeze the form instead of making it disabled. Is that
possible? Is there anyone who could give me any suggestion?

Thanks and regards,
D.

Found by using google:

http://www.dotnet2themax.com/blogs/fbalena/PermaLink,guid,6336502b-57c5-430d-9d37-7f9be484f6b3.aspx

Thanks,

Seth Rowe [MVP]
 
Back
Top