Progress Form

P

Pepi Tonas

I have a form that takes some time to load because it has to populate
some Data. I was trying to display a form on top of it with an
activity bar so that user can see that something's going on.

I have tried doing this and using a progress bar that counts up to 100
and then zeros down so that it should be constantly moving while the
main or background windows finishes loading.

The problem is that the "in progress window" doesn't display its
controls until the background window has finished its process, which
eliminates the sense of the progress window.

code is something like this

sub mainform_load()
dim frmProgress as New ProgressWindow
frmProgress.ShowDialog()

StartUpProcess()
end sub

with this one, mainform does nothing

while with this other, progress windows is not displayed until start
up process is not done

sub mainform_load()
StartUpProcess()

dim frmProgress as New ProgressWindow
frmProgress.ShowDialog()
end sub

As usual, I appreciate your help...
 
H

Herfried K. Wagner [MVP]

* Pepi Tonas said:
I have a form that takes some time to load because it has to populate
some Data. I was trying to display a form on top of it with an
activity bar so that user can see that something's going on.

I have tried doing this and using a progress bar that counts up to 100
and then zeros down so that it should be constantly moving while the
main or background windows finishes loading.

The problem is that the "in progress window" doesn't display its
controls until the background window has finished its process, which
eliminates the sense of the progress window.

You will have to do the background processing in a separate thread.

<http://www.devx.com/dotnet/Article/11358>
 
C

Cor

Hi Pepsi,

I have still not used it myself so not tested, but I saved it very well
maybe you can try it.

\\\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

I hope this helps a little bit?

Cor

"> I have a form that takes some time to load because it has to populate
 
P

Pepi Tonas

Thanks...

Hi Pepsi,

I have still not used it myself so not tested, but I saved it very well
maybe you can try it.

\\\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

I hope this helps a little bit?

Cor

"> I have a form that takes some time to load because it has to populate
 
C

Craig Vick [MSFT]

Hi Pepi,

To do what you want you would need to use more than one thread.

Craig VB.Net Team
 
L

Lubos Hrasko

Adding to what Craig said:

Start a second thread for your StartUpProcess and do your long running task.
In your current process, start the progress dialog. You will have to think
of a way to inturrupt and close your progress dialog when your long running
process has finished.

The trick here is, and problem I've seen other run into is; make sure you
run your progress dialog on the UI Thread, as if you don't... you could get
some strange results.

I could throw together a quick sample for you if you want, and also, I have
an 'infinite progress' control that is styled after the Windows 2000 boot
screen - if you think this would help, just let me know.

Cheers,
Lubos

Craig Vick said:
Hi Pepi,

To do what you want you would need to use more than one thread.

Craig VB.Net Team
--------------------------------------------------------------------
This reply is provided AS IS, without warranty (express or implied).

--------------------
From: Pepi Tonas <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.vb
Subject: Progress Form
Date: Mon, 12 Jan 2004 22:48:44 -0400
Lines: 36
Message-ID: <[email protected]>
NNTP-Posting-Host: sju-204-250-22-142.prw.net (204.250.22.142)
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de 1073962124 12230890 204.250.22.142 ([213891])
X-Newsreader: Forte Free Agent 1.93/32.576 English (American)
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08phx.gbl!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!f
u-berlin.de!uni-berlin.de!sju-204-250-22-142.prw.NET!not-for-mail
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.vb:172335
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

I have a form that takes some time to load because it has to populate
some Data. I was trying to display a form on top of it with an
activity bar so that user can see that something's going on.

I have tried doing this and using a progress bar that counts up to 100
and then zeros down so that it should be constantly moving while the
main or background windows finishes loading.

The problem is that the "in progress window" doesn't display its
controls until the background window has finished its process, which
eliminates the sense of the progress window.

code is something like this

sub mainform_load()
dim frmProgress as New ProgressWindow
frmProgress.ShowDialog()

StartUpProcess()
end sub

with this one, mainform does nothing

while with this other, progress windows is not displayed until start
up process is not done

sub mainform_load()
StartUpProcess()

dim frmProgress as New ProgressWindow
frmProgress.ShowDialog()
end sub

As usual, I appreciate your help...
 
P

Pepi Tonas

Adding to what Craig said:

Start a second thread for your StartUpProcess and do your long running task.
In your current process, start the progress dialog. You will have to think
of a way to inturrupt and close your progress dialog when your long running
process has finished.

The trick here is, and problem I've seen other run into is; make sure you
run your progress dialog on the UI Thread, as if you don't... you could get
some strange results.

I could throw together a quick sample for you if you want, and also, I have
an 'infinite progress' control that is styled after the Windows 2000 boot
screen - if you think this would help, just let me know.

Cheers,
Lubos

I would highly appreciate that. Do please.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top