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 8797239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:48:48+00:00 2026-06-13T23:48:48+00:00

I am making a media player, now.. I have added a realtime search function

  • 0

I am making a media player, now.. I have added a realtime search function to search for songs etc. (Some thing like WMP realtime search) i.e while you enter the keywords the searching happens.

During the searching process, accessing the database and loading an IEnumerable is done on another thread via a BackGroundProcess. The UI is updated by invoking a dispatcher of a UIElement.

This process is rather fast, but however while you enter the search keywords in the textbox, there seems to be a small lag, this is beacause the Listbox.ItemSource updating takes some time.
i.e say you want to search for “Adele”, when you type in “a”, the search function loads the results for “A”, but as we are typing the whole word “Adele” , it some time to display the “d” “e” “l” “e” and there is a slight lag in between these letters.

During this search process, when I stop updating the UI the search process seems very smooth, this only means to me that the Listbox is locking up the thread, so the rest of the player’s UI is stuck there while the Listbox is done with its processing.

So I believe if I can put the Listbox Control to another UI thread, I can maintain the smooth flow of the player irrespective of the time taken to load the Listbox.
FYI: Data Virutualization is there & ListBox has UI Virtualization is working

How can i put the ListBox control onto another UI Thread?
WPF, C#

Thanks in advance 🙂

  • 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-06-13T23:48:49+00:00Added an answer on June 13, 2026 at 11:48 pm

    If you are querying the database on every keypress – this is going to cause you some lag when typing fast (or even normally)

    You would be better off throttling the request, we use this to throttle on the dispatcher thread.

    public static class DispatcherExtensions
    {
        private static Dictionary<string, DispatcherTimer> timers =
            new Dictionary<string, DispatcherTimer>();
        private static readonly object syncRoot = new object();
    
        public static string DelayInvoke(this Dispatcher dispatcher, string namedInvocation,
            Action action, TimeSpan delay,
            DispatcherPriority priority = DispatcherPriority.Normal)
        {
            lock (syncRoot)
            {
                if (String.IsNullOrEmpty(namedInvocation))
                {
                    namedInvocation = Guid.NewGuid().ToString();
                }
                else
                {
                    RemoveTimer(namedInvocation);
                }
                var timer = new DispatcherTimer(delay, priority, (s, e) =>
                    {
                        RemoveTimer(namedInvocation);
                        action();
                    }, dispatcher);
                timer.Start();
                timers.Add(namedInvocation, timer);
                return namedInvocation;
            }
        }
    
    
        public static void CancelNamedInvocation(this Dispatcher dispatcher, string namedInvocation)
        {
            lock (syncRoot)
            {
                RemoveTimer(namedInvocation);
            }
        }
    
        private static void RemoveTimer(string namedInvocation)
        {
            if (!timers.ContainsKey(namedInvocation)) return;
            timers[namedInvocation].Stop();
            timers.Remove(namedInvocation);
        } 
    
    
    } 
    

    Assuming you are not using MVVM, you could easily use this like so in your button click

    Dispatcher.CurrentDispatcher.DelayInvoke("UpdateSearch",
           YourMethodThatStartsBackgroundThread,Timespan.FromSeconds(1));
    

    Also worth a note : f you are using 4.5 there is the Delay property on bindings you could look at.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, making a media player and need to know something. I have a menu
I am making a WPF application of a media player from scratch. I have
I am making media player and i have progress bar in it. When play
I am making a media player ,who can run in background. i have to
I'm making a media player application in android where one part of my screen
I am making a java applet player. It includes Java.Media package, and I am
I'm making a mock-media player program that allows the user to input,edit,delete and view
I'm starting on a project in making a customizable media player which can support
i am making a media player apps in this apps i want to set
I'm making a small media player where I add mediafiles to a listbox which

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.