Click here to Skip to main content
15,902,809 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: .NET & firefox Pin
Matthew Hazlett25-Jan-06 14:34
Matthew Hazlett25-Jan-06 14:34 
QuestionWorkaround for Raw sockets in Windows XP SP2? Pin
Tom Paluzzi25-Jan-06 4:52
Tom Paluzzi25-Jan-06 4:52 
QuestionCan C++ be used to create a powerful web app? Pin
larryfran24-Jan-06 19:24
larryfran24-Jan-06 19:24 
AnswerRe: Can C++ be used to create a powerful web app? Pin
James Gupta25-Jan-06 1:38
professionalJames Gupta25-Jan-06 1:38 
AnswerRe: Can C++ be used to create a powerful web app? Pin
Dave Kreskowiak25-Jan-06 1:53
mveDave Kreskowiak25-Jan-06 1:53 
AnswerRe: Can C++ be used to create a powerful web app? Pin
Kevin McFarlane26-Jan-06 6:52
Kevin McFarlane26-Jan-06 6:52 
QuestionHow to import C# structs into MC++ without loss of inheritance connectivity Pin
chervu24-Jan-06 10:45
chervu24-Jan-06 10:45 
QuestionFilling a ListView is too slow. Pin
luke72724-Jan-06 6:42
luke72724-Jan-06 6:42 
I've got a list of ~1500 items that I am putting into a ListView. Originally I was doing it in the main UI thread but it "freezes" the application for a few seconds. So I tried moving it to a BackgroundWorker, but the main UI thread still gets bogged down. In my ProgressChanged event handler I added Sleep(10), as a few examples suggest. The good news is that it works; the bad news is that it makes the operation take an order of magnitude longer. What can I do to speed this up?

private void fillListView(IList list)
{
        this.listView.Items.Clear();
        this.listView.BeginUpdate();
        this.progressBar.Visible = true;
        this.backgroundWorker.RunWorkerAsync(list);
}
private void backgroundWorker_DoWork(System.Object sender, System.ComponentModel.DoWorkEventArgs e)
{
    System.ComponentModel.BackgroundWorker worker = sender as System.ComponentModel.BackgroundWorker;
    IList list = (IList)e.Argument;
    for(System.Int32 i = 0; i < list.Count; i++)
    {
        System.Windows.Forms.ListViewItem item = getListViewItem(list[i]);
        // necessary or else the main UI thread will still "freeze"
        System.Threading.Thread.Sleep(10);
        System.Int32 progress = (System.Int32)System.Math.Ceiling((System.Single)(i + 1) / (System.Single)(list.Count) * 100.0f);
        worker.ReportProgress(progress, item);
    }
}
private void backgroundWorker_ProgressChanged(System.Object sender, System.ComponentModel.ProgressChangedEventArgs e)
{
    System.Windows.Forms.ListViewItem item = (System.Windows.Forms.ListViewItem)e.UserState;
    this.listView.Items.Add(item);
    this.progressBar.Value = e.ProgressPercentage;
}
private void backgroundWorker_RunWorkerCompleted(System.Object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
{
    this.progressBar.Visible = false;
    this.listView.EndUpdate();
}

AnswerRe: Filling a ListView is too slow. Pin
Ray Cassick24-Jan-06 7:14
Ray Cassick24-Jan-06 7:14 
GeneralRe: Filling a ListView is too slow. Pin
luke72724-Jan-06 9:04
luke72724-Jan-06 9:04 
AnswerRe: Filling a ListView is too slow. Pin
Daniel Grunwald24-Jan-06 8:48
Daniel Grunwald24-Jan-06 8:48 
GeneralRe: Filling a ListView is too slow. Pin
luke72724-Jan-06 9:14
luke72724-Jan-06 9:14 
AnswerRe: Filling a ListView is too slow. Pin
luke72724-Jan-06 21:04
luke72724-Jan-06 21:04 
GeneralRe: Filling a ListView is too slow. Pin
Daniel Grunwald25-Jan-06 4:16
Daniel Grunwald25-Jan-06 4:16 
GeneralRe: Filling a ListView is too slow. Pin
Dan Neely25-Jan-06 5:39
Dan Neely25-Jan-06 5:39 
AnswerRe: Filling a ListView is too slow. Pin
luke72725-Jan-06 7:34
luke72725-Jan-06 7:34 
QuestionCulture and TwoLetterISOLanguageName Pin
Alsvha24-Jan-06 3:40
Alsvha24-Jan-06 3:40 
AnswerRe: Culture and TwoLetterISOLanguageName Pin
lmoelleb24-Jan-06 21:18
lmoelleb24-Jan-06 21:18 
QuestionInvokeMember and [out] parameter from COM Pin
QuaKx23-Jan-06 20:50
QuaKx23-Jan-06 20:50 
Question2005 Posters Pin
Jack Puppy23-Jan-06 13:52
Jack Puppy23-Jan-06 13:52 
AnswerRe: 2005 Posters Pin
Paul Conrad23-Jan-06 18:45
professionalPaul Conrad23-Jan-06 18:45 
Questionvc 2005 and Manifests Pin
Swinefeaster23-Jan-06 13:32
Swinefeaster23-Jan-06 13:32 
QuestionPassword Textbox Pin
Paul Conrad23-Jan-06 10:58
professionalPaul Conrad23-Jan-06 10:58 
AnswerRe: Password Textbox Pin
Dave Kreskowiak23-Jan-06 11:02
mveDave Kreskowiak23-Jan-06 11:02 
GeneralRe: Password Textbox Pin
Paul Conrad23-Jan-06 12:19
professionalPaul Conrad23-Jan-06 12:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.