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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:49:26+00:00 2026-06-12T06:49:26+00:00

I am a wpf newbie so pardon anything that doesn’t sound right… I have

  • 0

I am a wpf newbie so pardon anything that doesn’t sound right…

I have a WPF application that when started loads many (20000+) items from my SQL database and stores them into an ObservableCollection which is created in the xaml.cs behind file.

I created a class whose constructor creates a thread and starts the thread and the thread loops infinitely.

public StatusChanged()
    {
        Thread thread = new Thread(new ThreadStart(ThreadProc));
        thread.Start();
    }

The way this thread gets started is by creating an instance of this thread class in my main window behind code (xaml.cs)

In this thread I have a while loop that does a few things that may be causing my UI window to become unresponsive:

  1. infinite while loop that runs a sql command checking to see if a bit flag has changed for any of the items in the database. if none are found, the thread sleeps 3 seconds and the loop continues

  2. when rows are returned from the database, I loop through every row and find the changed attribute and modify my ObservableCollection as well as modifying the bit flag in the database by running a SQL Update command for each one. The thread then sleeps for 3 seconds again and the loop continues.

This is an overview of what is occurring. When rows are returned with from the database and the work is being done from point 2), the UI can become unresponsive. When I try to click a button it normally works say 75%+ of the time, but 25% of the time the UI is unresponsive and nothing happens. This is very bad for my app.

Based on my example, what do you think is making the UI unresponsive? could it be…

  1. the while loop that is looping through every row returned by the database?

  2. Updating the observable collection inside of that while loop ^^ as well as making a sql update call for each item.

  3. The way my thread is started and sleeps and created by an instance from the xaml.cs code?

  • 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-12T06:49:27+00:00Added an answer on June 12, 2026 at 6:49 am

    If the Observable collection of 20000+ items is bound to the UI, the UI might need to be updated when the items are modified. This can be very expensive for the UI thread causing the UI to become unresponsive.

    A couple of suggestions to try:

    1. Slim down on the number of items
    2. Use VirtualizingStackPanels to prevent the UI from updating unseen items
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a newbie in WPF applications. I want to create a application that displays
I have a newbie WPF question. Imagine my user control has a namespace declaration
WPF controls have certain properties (UserControl.Resources, UserControl.CommandBindings) that can have items added to them
I'm a newbie with WPF and c# and have a (probably very simple) problem.
I'm a newbie to WPF and I'm developing a brand new windows desktop application
First, fair warning: I am a complete newbie with C# and WPF. I have
i'm using sharpdevelop to program WPF application(I'm newbie to WPF i've knowledge of VB
I have a WPF UserControl that I'd like to inject dependencies into. What's the
I'm a WPF newbie, so pardon me in advance if this is a dumb
newbie question, please forgive... I'm developing a Wpf UserControl that will eventually be bound

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.