469,903 Members | 1,499 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

opening a window from another's load event

I want to open a window (the called window) - and perhaps run a progressbar,
etc - from a calling window's load event. The calling window is loading a
large datatable before it completes its load event.

The calling window itself is a child window in an mdi app. I'm having a
terrible time trying to do this, as the called window never fully opens
unless it's called via showdialog, but this is not what I want, because I
want it to close when the progressbar completes (or when the calling window
finally loads, which is the same thing).

Thanks for any help.

Bernie Yaeger
Nov 20 '05 #1
2 1026
Cor
Hi Bernie,

I would make a seperate thread to load that dataset, and not succeed in
getting that fill to give information use "on and off" gif's that are
changed from throwed events every 5 seconds in the the thread.

I have here pasted some code that Armin did made for this, I still did not
check it, but I think it is a good start for your question.

And before you ask it, you can kill a thread with "myThread.abort"

I hope you a little bit?

Cor

\\\By Armin Zingler
In a new project, add a button to the Form. Also add the following code:

Private m_Thread As MyThread

Private Sub Button1_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click

m_Thread = New MyThread
AddHandler m_Thread.Progress, AddressOf OnProgress
AddHandler m_Thread.Done, AddressOf OnDone
m_Thread.Start()
End Sub

Public Delegate Sub ProgressDelegate(ByVal Progress As Integer)

Private Sub OnProgress(ByVal Progress As Integer)
If Me.InvokeRequired Then
Me.Invoke(New ProgressDelegate( _
AddressOf OnProgress _
), New Object() {Progress})
Else
Me.Button1.Text = Progress.ToString
End If
End Sub

Private Sub OnDone()
m_Thread = Nothing
End Sub
////
Class MyThread
Public Event Progress(ByVal Progress As Integer)
Public Event Done()

Private m_Thread As Thread

Public Sub Start()
m_Thread = New Thread(AddressOf ThreadStart)
m_Thread.Start()
End Sub

Private Sub ThreadStart()
Dim i As Integer
For i = 1 To 100
Thread.Sleep(100)
RaiseEvent Progress(i)
Next
RaiseEvent Done()
End Sub

End Class
///

Nov 20 '05 #2
Hi Cor,

Thanks very much. I will be testing this code today.

Thanks again,

Bernie

"Cor" <no*@non.com> wrote in message
news:ua**************@TK2MSFTNGP12.phx.gbl...
Hi Bernie,

I would make a seperate thread to load that dataset, and not succeed in
getting that fill to give information use "on and off" gif's that are
changed from throwed events every 5 seconds in the the thread.

I have here pasted some code that Armin did made for this, I still did not
check it, but I think it is a good start for your question.

And before you ask it, you can kill a thread with "myThread.abort"

I hope you a little bit?

Cor

\\\By Armin Zingler
In a new project, add a button to the Form. Also add the following code:

Private m_Thread As MyThread

Private Sub Button1_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click

m_Thread = New MyThread
AddHandler m_Thread.Progress, AddressOf OnProgress
AddHandler m_Thread.Done, AddressOf OnDone
m_Thread.Start()
End Sub

Public Delegate Sub ProgressDelegate(ByVal Progress As Integer)

Private Sub OnProgress(ByVal Progress As Integer)
If Me.InvokeRequired Then
Me.Invoke(New ProgressDelegate( _
AddressOf OnProgress _
), New Object() {Progress})
Else
Me.Button1.Text = Progress.ToString
End If
End Sub

Private Sub OnDone()
m_Thread = Nothing
End Sub
////
Class MyThread
Public Event Progress(ByVal Progress As Integer)
Public Event Done()

Private m_Thread As Thread

Public Sub Start()
m_Thread = New Thread(AddressOf ThreadStart)
m_Thread.Start()
End Sub

Private Sub ThreadStart()
Dim i As Integer
For i = 1 To 100
Thread.Sleep(100)
RaiseEvent Progress(i)
Next
RaiseEvent Done()
End Sub

End Class
///

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Clinton Goff | last post: by
3 posts views Thread by Mehmet Gunacti | last post: by
14 posts views Thread by D. Alvarado | last post: by
6 posts views Thread by John Smith | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.