473,395 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Show processing progress

Hello,

What is the best practice to show a window/form of some
animation while processing is going on in the back ground.

I want the user to see something while some processing is
taking place.

TIA
Nov 20 '05 #1
6 15155
You want to look into threading.

In short,put the long running task on a different thread of execution.

If you are trying to update a user interface (like doing a status bar for
example) check this out from gotdotnet.

http://samples.gotdotnet.com/quickst...rshalling.aspx

--

Justin Weinberg
Designing a PrintDocument? Drawing to forms?
Check out GDI+ Architect at www.mrgsoft.com
"Shawn Regan" <sh****@pts1.com> wrote in message
news:0d****************************@phx.gbl...
Hello,

What is the best practice to show a window/form of some
animation while processing is going on in the back ground.

I want the user to see something while some processing is
taking place.

TIA

Nov 20 '05 #2
"Shawn Regan" <sh****@pts1.com> schrieb
What is the best practice to show a window/form of some
animation while processing is going on in the back ground.

I want the user to see something while some processing is
taking place.


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
Start the application and press the button.

If you've got any questions, don't hesitate to ask.
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html

Nov 20 '05 #3
Cor
"Armin Zingler"

If you've got any questions, don't hesitate to ask.

No questions, just my compliments

Nice example

:-)

Cor
Nov 20 '05 #4
* "Shawn Regan" <sh****@pts1.com> scripsit:
What is the best practice to show a window/form of some
animation while processing is going on in the back ground.

I want the user to see something while some processing is
taking place.


Progress Dialog (for C#, can be converted to VB.NET):

<http://www.codeproject.com/cs/miscctrl/progressdialog.asp>

Multithreading + Windows Forms:

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

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Improve your quoting style:
<http://learn.to/quote>
<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #5
On 2003-10-29, Armin Zingler <az*******@freenet.de> wrote:
"Shawn Regan" <sh****@pts1.com> schrieb
What is the best practice to show a window/form of some
animation while processing is going on in the back ground.

I want the user to see something while some processing is
taking place.


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
Start the application and press the button.

If you've got any questions, don't hesitate to ask.


Very nice...

--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #6
On 2003-10-29, Shawn Regan <sh****@pts1.com> wrote:
Hello,

What is the best practice to show a window/form of some
animation while processing is going on in the back ground.

I want the user to see something while some processing is
taking place.

TIA


You all ready got some exelent advice, but I'd thought I'd throw out an
additional resource for your consumption... This is part one of a 3
part article on Windows forms and threading. The code is in C#, but the
principals apply equally to VB.NET and the code is pretty trivial to
convert to VB.NET:

http://msdn.microsoft.com/library/de...ms06112002.asp

--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: jcfilth | last post by:
Hello, I have created an asp.net web page with 3 datagrids. Every datagrid binds to a diferent sql query, against a sql server. I first bind one, then the other and then the last, all using code...
3
by: Jeff S | last post by:
I'm enabling users to upload files to the server. I'd like to show them some indication of percent complete. How can this be done? Thanks!
9
by: Martin Ho | last post by:
My application should check for new updates when user chooses this option in the menu. It should go online and check the flag and compare with current flag in the programs directory. If version is...
7
by: Loane Sharp | last post by:
Hi there I'm currently using WebClient.DownloadFile to download a file from the server to my local disk. Is there a way to show the progress of the file download? Best regards Loane
0
by: remya1000 | last post by:
by using FTP i can send files to server using vb.net. if the file is big, then it will take some time to complete the sending process to server.or if we were sending 3-4 files to the server one by...
5
dzenanz
by: dzenanz | last post by:
I have JSP web-form which uploads a file. In java code, I have a statement like this: for all lines in txt file uploaded call DB stored procedure As this web interface should be used over a...
1
by: Swan | last post by:
Can anyone plz tell me,I have OCX created Http upload control.In that I am sending chunk wise data.Everything is working fine.My question is-how can I show Upload progress or Uploading...
7
by: yogarajan | last post by:
Dear all i am uploading one large file it will take time on that time i will show processing image pls help me
0
by: Sathishkumar K | last post by:
Hi All, I am facing problem while displaying the progress bar form on top of application main form. Let me explain bit more details. I running the main form through Application.Run(new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.