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

datareader to load listbox - thread safety

i have a sqldatareader that could potentially pull in many rows, maybe
thousands, and put them into a listBox on a windows form. i want to do it
as fast as possible so right away i think about a new thread. well scratch
that, fast i can't really control. i want the user interface to remain
responsive during the sqldatareader load. after it loads, i do this

Do While drReader.Read
Me.lstValues.Items.Add(drReader.Item(0))
Loop

to fill the listbox. my question is, if i load the datareader on a worker
thread i DO have to use the .Invoke method because this isn't thread safe
right? is there a better way to load the list box than i am thinking?

Nov 20 '05 #1
1 2840
how will a datatable be better? i don't plan to update the data, just show
it to the user. that is why i chose a datareader - they're seemingly faster

Rulin Hong wrote:
How about putting data in a datatable first, then use invoke method.

"Josh Golden" wrote:
i have a sqldatareader that could potentially pull in many rows,
maybe thousands, and put them into a listBox on a windows form. i
want to do it as fast as possible so right away i think about a new
thread. well scratch that, fast i can't really control. i want the
user interface to remain responsive during the sqldatareader load.
after it loads, i do this

Do While drReader.Read
Me.lstValues.Items.Add(drReader.Item(0))
Loop

to fill the listbox. my question is, if i load the datareader on a
worker thread i DO have to use the .Invoke method because this isn't
thread safe right? is there a better way to load the list box than
i am thinking?

Nov 20 '05 #2

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

Similar topics

2
by: rob | last post by:
I'm having some trouble with this.. My VB datareader seems to skip the first record in the reader. I've looked at my query in enterprise manager to confirm what I am suppose to receive back,...
4
by: Jonathan Burd | last post by:
Greetings everyone, Here is a random string generator I wrote for an application and I'm wondering about the thread-safety of this function. I was told using static and global variables cause...
9
by: Alexander Fleck | last post by:
Hi, I' ve to make a software module thread safe. I know how to realize that and what' re the main topics of thread safety. But I don' t know how thread safety can be tested. I read about a test...
2
by: Jake S | last post by:
Hi all, Is it possibele to set the datasource of a dropdown list to a datareader? When I try to the only column I receive is a column populated by the datasource name repeated the amount of...
5
by: Rob Wire | last post by:
For the code below, how could I add an item in the drop down lists for both company and location to be an "All" selection that would send to the stored proc. spRptAttachments a value of "%" so...
2
by: Andrei Pociu | last post by:
In a typical ASP .NET Web Application (website), I'm currently using a class where I declare some public static objects. For example there's the place where I initialize the SqlConnection. Also...
6
by: fniles | last post by:
I am using VB.NET 2003 and a socket control to receive and sending data to clients. As I receive data in 1 thread, I put it into an arraylist, and then I remove the data from arraylist and send it...
10
by: jimmy | last post by:
Hi again, sorry for posting two questions so close together but im working on a school project which is due in soon and running into some difficulties implementing the database parts. I have the...
3
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm trying to add a datagridview control to a Windows Form to display read-only information in visual basic 2005. My understanding is that datareader will be faster for this purpose. I have the...
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: 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...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.