Home All Groups Group Topic Archive Search About

Multithreaded Updating of StatusBar

Author
2 Jul 2006 1:35 AM
Derek Hart
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

Author
2 Jul 2006 1:52 AM
iwdu15
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
Author
2 Jul 2006 1:53 AM
iwdu15
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
Author
2 Jul 2006 5:58 AM
Cor Ligthert [MVP]
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

Show quoteHide quote
"Derek Hart" <derekmh***@yahoo.com> schreef in bericht
news:%23VPzRfXnGHA.4636@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
>
Author
2 Jul 2006 5:57 PM
Derek Hart
I did not understand your questions Cor.  Can you elaborate?

Derek


Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:eGh7exZnGHA.3436@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" <derekmh***@yahoo.com> schreef in bericht
> news:%23VPzRfXnGHA.4636@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
>>
>
>
Author
2 Jul 2006 6:53 PM
Cor Ligthert [MVP]
>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

Show quoteHide quote
> Derek
>
>
> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
> news:eGh7exZnGHA.3436@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" <derekmh***@yahoo.com> schreef in bericht
>> news:%23VPzRfXnGHA.4636@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
>>>
>>
>>
>
>
Author
2 Jul 2006 10:35 PM
Derek Hart
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.


Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:%23NIQyignGHA.4784@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]" <notmyfirstn***@planet.nl> wrote in message
>> news:eGh7exZnGHA.3436@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" <derekmh***@yahoo.com> schreef in bericht
>>> news:%23VPzRfXnGHA.4636@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
>>>>
>>>
>>>
>>
>>
>
>