473,408 Members | 2,888 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,408 software developers and data experts.

Updating counter during data load

I am loading data through a OleDbDatareader. The load is
started from a form by the user, but the actual load is
done in a separate class, which is accessed from my form.

Now, I want the user to see how the load is progressing,
so I have a counter textbox, which I have passed to the
load object as a texbox (ByRef). For every 100 records
that are loaded, I update the Text attribute for the
textbox with a new number. However, the textbox don't
seem to show any number until the load is over; at that
point it does show the number of records loaded. I
therefore assume that the textbox does get updated, but
that perhaps and update of the form and its objects,
isn't performed until after the load.

Any hints to how I can force the textbox object to be
updated on the screen?
Regards,

Frank
Nov 20 '05 #1
4 1365
Cor
Hi Frank,
The code beneath is from Armin I did send an hour ago to Crirus,
if you have problems with it, you can do a less nice code like this (rough
typed)
\\\
do while x ' and x is a boolean wich you have public in the class that reads
the data
threadin.thread.sleep(50)
application.doevents
loop
///

But this is much nicer, I did not try it till now, but it looks so nice.

\\\ by Armin
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
"Frank" <an*******@discussions.microsoft.com> schrieb
I am loading data through a OleDbDatareader. The load is
started from a form by the user, but the actual load is
done in a separate class, which is accessed from my form.

Now, I want the user to see how the load is progressing,
so I have a counter textbox, which I have passed to the
load object as a texbox (ByRef). For every 100 records
that are loaded, I update the Text attribute for the
textbox with a new number. However, the textbox don't
seem to show any number until the load is over; at that
point it does show the number of records loaded. I
therefore assume that the textbox does get updated, but
that perhaps and update of the form and its objects,
isn't performed until after the load.

Any hints to how I can force the textbox object to be
updated on the screen?


There are two ways: Application.DoEvents or multithreading.

Concerning multithreading:
http://groups.google.com/groups?thre...280a%40phx.gbl

--
Armin

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

Nov 20 '05 #3
Thanks, that was just the pointer that I needed.

Frank
-----Original Message-----
"Frank" <an*******@discussions.microsoft.com> schrieb
I am loading data through a OleDbDatareader. The load is started from a form by the user, but the actual load is
done in a separate class, which is accessed from my form.
Now, I want the user to see how the load is progressing, so I have a counter textbox, which I have passed to the
load object as a texbox (ByRef). For every 100 records
that are loaded, I update the Text attribute for the
textbox with a new number. However, the textbox don't
seem to show any number until the load is over; at that
point it does show the number of records loaded. I
therefore assume that the textbox does get updated, but
that perhaps and update of the form and its objects,
isn't performed until after the load.

Any hints to how I can force the textbox object to be
updated on the screen?
There are two ways: Application.DoEvents or

multithreading.
Concerning multithreading:
http://groups.google.com/groups?threadm=0d9701c39e3b% 24cda0c370%24a601280a%40phx.gbl
--
Armin

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

.

Nov 20 '05 #4
Thanks a lot.

Frank
-----Original Message-----
Hi Frank,
The code beneath is from Armin I did send an hour ago to Crirus,if you have problems with it, you can do a less nice code like this (roughtyped)
\\\
do while x ' and x is a boolean wich you have public in the class that readsthe data
threadin.thread.sleep(50)
application.doevents
loop
///

But this is much nicer, I did not try it till now, but it looks so nice.
\\\ by Armin
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 #5

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

Similar topics

6
by: Hennie de Nooijer | last post by:
Hi, Currently we're a building a metadatadriven datawarehouse in SQL Server 2000. We're investigating the possibility of the updating tables with enormeous number of updates and insert and the...
11
by: TomCat | last post by:
Hello, can anyone send me a link or even some sample of script that counts visits to a website ? Thanks, TomCat
3
by: Poul Møller Hansen | last post by:
Hi, I need an auto incrementing field that will contain values like N000001, N000002, N000003 etc. I think the way is to use the value from an identity field in a stored procedure that is...
1
by: Chris Jackson | last post by:
I'm a novice Access user and am not sure how to solve the following problem. Any help with the following would be greatly appreciated! I have two tables with identical structures, the first holds...
2
by: George | last post by:
The flow of my app is as follows 1) Pull up an order and change the quantity of a textbox item. (Ex: change the quantity from 1 to 2 2) Click on the Update button 3) When the page posts back you...
4
by: Darrel | last post by:
I'm creating a table that contains multiple records pulled out of the database. I'm building the table myself and passing it to the page since the table needs to be fairly customized (ie, a...
4
by: Geoff | last post by:
Hi I'm hoping somebody can help me with the following problem that has occurred to me. Suppose I have two tables in an SQL Server database. Let's call these tables A and B. Assume that A has...
0
by: preeti13 | last post by:
i have a two tables employeenominations and reason if someone storing a data first time it will store into the employeenominations table if name is already exist it will store into the reason table...
2
by: =?Utf-8?B?TUNN?= | last post by:
I have an asp.net page that contains an update panel. Within the update panel, controls get added dynamically. During partial page post backs the controls within the panel will change. I have a...
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
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.