PC Review


Reply
Thread Tools Rate Thread

datareader to load listbox - thread safety

 
 
Josh Golden
Guest
Posts: n/a
 
      8th Jul 2004
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?



 
Reply With Quote
 
 
 
 
Josh Golden
Guest
Posts: n/a
 
      9th Jul 2004
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?



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Thread safety of DataTable class - Filling on background thread OK? Alan Cobb Microsoft ADO .NET 9 1st Jul 2006 07:27 AM
thread safety Gravy Microsoft Dot NET Framework Forms 7 3rd Dec 2004 03:17 AM
C# Thread safety Sherif ElMetainy Microsoft C# .NET 6 2nd Nov 2004 02:07 PM
Thread safety ?? Support Microsoft C# .NET 10 8th Sep 2004 07:13 PM
Thread safety ?? Support Microsoft Dot NET 10 8th Sep 2004 07:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:52 AM.