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

  • SEARCH
  • Home
  • 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 7592345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:53:00+00:00 2026-05-30T20:53:00+00:00

I have an Asynchronous BindingList that contains objects that are manipulated on a worker

  • 0

I have an Asynchronous BindingList that contains objects that are manipulated on a worker thread and bound to a BindingSource on the Main UI thread with a BindingSource bound to a DataGridView.

Is there anyway possible to locate objects in my BindingList without iterating through the list?

I’ve looked under the hood of LINQ and it’s basically a sugar coated foreach loop. Also from my understand if I implement IBindingList.Find() it’s nothing more than a for-loop…

I’ve “tried” to synchronize/map my BindingList to a Dictionary that mirrors my BindingList and using the Dictionary to located objects and pass the results(index) to my BindingList but this is not working because there is just too much adding and removing of the objects and I can’t keep things organized.

This is a high-performance app that’s dealing with real-time high frequency data from the stock market. That’s why I can’t iterate through the BindingList, it’s just too inefficient.

Can someone please give me some advice and/or solutions.

  • 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. Editorial Team
    Editorial Team
    2026-05-30T20:53:02+00:00Added an answer on May 30, 2026 at 8:53 pm

    So some sort of fast lookup binding list… Here is one I prepared earlier.

    This is the ‘synchronize/map’ approach you referred to. I’ve used this before for fast ticking data, where main bottleneck was looking up items in the list. I believe I’ve covered all the methods required to keep in sync or ‘organised’. You might to add a test for AddRange – I don’t have a decompiler to hand, I’m not sure if it just calls InsertItem.

    Obviously you have a direct trade-off here of greater memory use and insert time, maintaining two lists, but for fast ticking data, that’s normally a very acceptable trade-off for improved lookup times.

    Use the class like you would a BindingList, but when you need look up an item quickly, use the FastFind method.

    public class FastLookupBindingList<TKey, TVal> : BindingList<TVal>
    {
        private readonly IDictionary<TKey, TVal> _dict = new Dictionary<TKey, TVal>();
        private readonly Func<TVal, TKey> _keyFunc;
    
        public FastLookupBindingList(Func<TVal, TKey> keyFunc)
        {
            _keyFunc = keyFunc;
        }
    
        public FastLookupBindingList(Func<TVal, TKey> keyFunc, IList<TVal> sourceList) : base(sourceList)
        {
            _keyFunc = keyFunc;
    
            foreach (var item in sourceList)
            {
                var key = _keyFunc(item);
                _dict.Add(key, item);
            }
        }
    
        public TVal FastFind(TKey key)
        {
            TVal val;
            _dict.TryGetValue(key, out val);
            return val;
        }
    
        protected override void InsertItem(int index, TVal val)
        {
            _dict.Add(_keyFunc(val), val);
            base.InsertItem(index, val);
        }
    
        protected override void SetItem(int index, TVal val)
        {
            var key = _keyFunc(val);
            _dict[key] = val;
    
            base.SetItem(index, val);
        }
    
        protected override void RemoveItem(int index)
        {
            var item = this[index];
            var key = _keyFunc(item);
            _dict.Remove(key);
    
            base.RemoveItem(index);
        }
    
        protected override void ClearItems()
        {
            _dict.Clear();
            base.ClearItems();
        }
    }
    

    Usage:

    public class Person
        {
            public int Id { get; set; }
            public string Name { get; set; }
        }
    
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            var keyedBindingList = new FastLookupBindingList<int, Person>(p => p.Id)
                                       {
                                           new Person {Id = 1, Name = "Joe"}, 
                                           new Person {Id = 2, Name = "Josephine"}
                                       };
            var person = keyedBindingList.FastFind(2);
            var unkonwn = keyedBindingList.FastFind(4);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a basic asynchronous task that performs a web request. The thread is
Or can we have asynchronous code that executes in the same thread.
I have some asynchronous operations being performed on the main thread of my application.
I have a rails app that has asynchronous processing, and I'm having trouble getting
I have a legacy C++ application that uses DDS for asynchronous communication/messaging. I need
I have a contact us form that uses Ajax (i.e. relies on asynchronous requests).
My form receives asynchronous callbacks from another object on random worker threads. I have
I have an asynchronous local SSRS 2005 report that is of variable height and
I have several asynchronous jobs that I would like to transparently handle the exception
I have a asynchronous task like so: dispatch_async(dispatch_get_main_queue(), ^{ myAsyncMethodsHere; }); Is there a

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.