Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 106477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:36:10+00:00 2026-05-11T01:36:10+00:00

EDIT: It is not a listbox. My mistake. It is a list view. I

  • 0

EDIT: It is not a listbox. My mistake. It is a list view.

I have a list view control that’s driving me nuts. It is a multi-select list box, so if the user selects 5000 rows, then de-selects them by selecting a single row, the SelectedIndexChanged fires 5001 times. This causes my app to hang.

I’m trying to use threads to count the number of times that the event WOULD have fired, and then letting the last iteration do all the actual work.

Here’s the code I started with. The big catch: I need the ‘do fancy calculations’ to be in the same thread as the calling events due to items out of my control.

EDIT: I know that this code doesn’t work. The Join() blocks the current thread which negates the entire purpose of creating the thread. My question is : How do I do something LIKE this.

My biggest problem isn’t creating the thread. It’s that my ‘do fancy’ has to be in the same thread.

    void IncrPaintQueue()     {         PaintQueue++;         Thread.Sleep(100);     }      int PaintQueue = 0;      private void SegmentList_SelectedIndexChanged(object sender, EventArgs e)     {         // We need to know how many threads this may possibly spawn.         int MyQueue = PaintQueue;          // Start a thread to increment the counter.         Thread Th = new Thread(IncrPaintQueue);         Th.IsBackground = true;         Th.Start();         Th.Join();          // if I'm not the last thread, then just exit.          // The last thread will do the right calculations.         if (MyQueue != PaintQueue - 1)             return;          // Reset the PaintQueue counter.         PaintQueue = 0;          // ... do fancy calculations here...     } 

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T01:36:11+00:00Added an answer on May 11, 2026 at 1:36 am

    I remember solving this issue before:

    A better way perhaps for you would be to put a minimal delay in your ItemSelectionChange Handler. Say — 50ms. Use a timer, Once the selection changes, restart the timer. If the selection changed more than once within the delay period, then the original is ignored, but after the delay has expired, the logic is executed.

    Like this:

    public class SelectionEndListView : ListView { private System.Windows.Forms.Timer m_timer; private const int SELECTION_DELAY = 50;  public SelectionEndListView() {    m_timer = new Timer();    m_timer.Interval = SELECTION_DELAY;    m_timer.Tick += new EventHandler(m_timer_Tick); }  protected override void OnSelectedIndexChanged(EventArgs e) {    base.OnSelectedIndexChanged(e);     // restart delay timer    m_timer.Stop();    m_timer.Start(); }  private void m_timer_Tick(object sender, EventArgs e) {    m_timer.Stop();     // Perform selection end logic.    Console.WriteLine('Selection Has Ended'); } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two views of some data: a list view (a ListBox now, but
I have simple SL user control. A listbox which shows all customers and on
Edit : The basic problem is binding a List to ListBox(or any other control).
I have a user control containing a listbox. I want to bind to the
I have a Listbox, that has a Checkbox as part of the item template.
Sometimes users require to change information in SharePoint list item that is not editable
I have the following data trigger on the ListBoxItems in my Multi-selection ListBox <DataTrigger
I have a listbox that might contain thousands of items. I need a way
I have a WPF Popup control with a ListBox and a Button in it.
So I'm building a tool that allows a user to edit a whole bunch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.