473,385 Members | 1,582 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,385 software developers and data experts.

Multithreaded Updating of StatusBar

I am using a status bar to show progress for a long database update. With
the single threading, the GUI often gets stuck and does not show updating,
especially when the user clicks to another program and tries to come back.
The multithreading stuff is looking somewhat complicated. Can somebody show
me a pre-built function on how to continuously update a status bar while
another process is running. Should I run the database process on a new
thread and keep the status bar on the main thread?

Derek
Jul 2 '06 #1
6 1863
controls belong to the thread they were created on, so unless you create your
progressbar dynamically from a new thread, it belongs to your programs main
thread. so in order to change the progress bar from another thread, you need
to use Me.Invoke(). you shouldnt access other threads object and such. create
a sub on the main thread like so

Private Sub ChangeProgValue(byval val as integer)

Me.progressbar1.Value = val

end sub

then create a delagate

Private Delegate Sub ProgDelegate(byval y as Integer)

then when you want to change the progress value on the other thread do this
in a sub of the second thread

Dim x as new ProgDelegate(AddressOf ChangeProgValue)
Dim obj() as Object = {some value to change progressbar}

Me.Invoke(x, obj)

that should work for ya

--
-iwdu15

Jul 2 '06 #2
controls belong to the thread they were created on, so unless you create your
progressbar dynamically from a new thread, it belongs to your programs main
thread. so in order to change the progress bar from another thread, you need
to use Me.Invoke(). you shouldnt access other threads object and such. create
a sub on the main thread like so

Private Sub ChangeProgValue(byval val as integer)

Me.progressbar1.Value = val

end sub

then create a delagate

Private Delegate Sub ProgDelegate(byval y as Integer)

then when you want to change the progress value on the other thread do this
in a sub of the second thread

Dim x as new ProgDelegate(AddressOf ChangeProgValue)
Dim obj() as Object = {some value to change progressbar}

Me.Invoke(x, obj)

that should work for ya

--
-iwdu15
Jul 2 '06 #3
Derek,

I am always currious which process can run aside a DataBase Update with its
chance on all kind of errors, can you explain it? Moreover because that you
said that you had problems realizing your problem with the progressbar. What
is maybe difficult with the Fill but not with the Update and keeps
automaticly the form alive.

Cor

"Derek Hart" <de********@yahoo.comschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
>I am using a status bar to show progress for a long database update. With
the single threading, the GUI often gets stuck and does not show updating,
especially when the user clicks to another program and tries to come back.
The multithreading stuff is looking somewhat complicated. Can somebody
show me a pre-built function on how to continuously update a status bar
while another process is running. Should I run the database process on a
new thread and keep the status bar on the main thread?

Derek

Jul 2 '06 #4
I did not understand your questions Cor. Can you elaborate?

Derek
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:eG**************@TK2MSFTNGP02.phx.gbl...
Derek,

I am always currious which process can run aside a DataBase Update with
its chance on all kind of errors, can you explain it? Moreover because
that you said that you had problems realizing your problem with the
progressbar. What is maybe difficult with the Fill but not with the Update
and keeps automaticly the form alive.

Cor

"Derek Hart" <de********@yahoo.comschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
>>I am using a status bar to show progress for a long database update. With
the single threading, the GUI often gets stuck and does not show updating,
especially when the user clicks to another program and tries to come back.
The multithreading stuff is looking somewhat complicated. Can somebody
show me a pre-built function on how to continuously update a status bar
while another process is running. Should I run the database process on a
new thread and keep the status bar on the main thread?

Derek


Jul 2 '06 #5
>I did not understand your questions Cor. Can you elaborate?
>
What is the deeper reason that you use multithreading.

In other words which processes run assynchonosly side by side.

Cor
Derek
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:eG**************@TK2MSFTNGP02.phx.gbl...
>Derek,

I am always currious which process can run aside a DataBase Update with
its chance on all kind of errors, can you explain it? Moreover because
that you said that you had problems realizing your problem with the
progressbar. What is maybe difficult with the Fill but not with the
Update and keeps automaticly the form alive.

Cor

"Derek Hart" <de********@yahoo.comschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
>>>I am using a status bar to show progress for a long database update.
With the single threading, the GUI often gets stuck and does not show
updating, especially when the user clicks to another program and tries to
come back. The multithreading stuff is looking somewhat complicated. Can
somebody show me a pre-built function on how to continuously update a
status bar while another process is running. Should I run the database
process on a new thread and keep the status bar on the main thread?

Derek



Jul 2 '06 #6
I have a long database process that runs, and a status bar that updates
showing progress. If the user moves to another application and moves back
to my app, the status bar is in frozen mode and does not update until the
end of the database process.
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
I did not understand your questions Cor. Can you elaborate?
What is the deeper reason that you use multithreading.

In other words which processes run assynchonosly side by side.

Cor
>Derek
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:eG**************@TK2MSFTNGP02.phx.gbl...
>>Derek,

I am always currious which process can run aside a DataBase Update with
its chance on all kind of errors, can you explain it? Moreover because
that you said that you had problems realizing your problem with the
progressbar. What is maybe difficult with the Fill but not with the
Update and keeps automaticly the form alive.

Cor

"Derek Hart" <de********@yahoo.comschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl.. .
I am using a status bar to show progress for a long database update.
With the single threading, the GUI often gets stuck and does not show
updating, especially when the user clicks to another program and tries
to come back. The multithreading stuff is looking somewhat complicated.
Can somebody show me a pre-built function on how to continuously update
a status bar while another process is running. Should I run the database
process on a new thread and keep the status bar on the main thread?

Derek



Jul 2 '06 #7

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

Similar topics

0
by: Gijs Korremans | last post by:
Hi, I'm trying to debug a multithreaded windowsNT service with Boa Constructor but it's not working. I don't know how to debug a service (there's nothing on the internet about that) so I've made...
4
by: Tonya | last post by:
Hi, Does anyone know how i can add controls to a progress bar. I have searched the internet but could not find any examples. what i want to add is a progress bar and a button. thx
18
by: Andrew Poulos | last post by:
If I manage to call the following bit of javascript in IE and MZ w = window.open("", "s", 'status=no,resizable=no,width=450,height=450'); I get a window that is not resizable and without a...
5
by: Ken Saganowski | last post by:
Does anyone have any sample code for a multi threaded form that refreshes itself while an extended operation is executing: Example: I am updating a local dataset which could potentially have...
4
by: Dwight Trumbower | last post by:
There has to be a better way than the following code. My main area of question is getting data from a cell. This following statement is the only way I can get it to work. Just seems like to much...
3
by: TonyM | last post by:
Hi all, I have an application with a few different Windows forms. I am trying to update a statusbar panel's text that is in the main form, from another form. When I set the statusbar and the...
3
by: Christian Filzwieser | last post by:
Hy I created a WebControl called StatusBar with a static function public static void SetText(string text) { MyVariable = Text } and on Page Load I set MyVariable to the Label in my WebControl....
9
by: Christian Blackburn | last post by:
Hi Gang, I've had this happen with a couple of controls now, but my patience has worn thin. Can somebody tell me why I can read/write to most objects on my form from my module, but not when...
3
by: S. Viswanathan | last post by:
Hi everybody! In VB.NET 2005, MenuStrip and Statusstrip controls added. When the mouse over on the Menuitem its corresponding Tooptip text should be displayed in the statusstrip. How to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.