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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:53:35+00:00 2026-05-25T05:53:35+00:00

I am currently working on a C# wpf project. The files are exported data

  • 0

I am currently working on a C# wpf project. The files are exported data from a database which are in the form of an SQL statement. For each line that the file reads in it executes the statement to perform the action on the database inside the MySQL server.

The task is run inside a background worker which reports progress, so each time a line has been executed on the MySQL Server it calls the progress changed event to update a progress bar so that the user known how much the program has restored to the server.

However, when it gets to a certain point the progress changed event crashes with a stack overflow exception. Below is the code that updates the progress bar which is where the stackoverflow exception occurrs.

void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
    window.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, new System.Windows.Threading.DispatcherOperationCallback(delegate
    {
        progressRestore.IsIndeterminate = false;
        progressRestore.Value = e.ProgressPercentage;
        lblRestProgress.Content = e.ProgressPercentage + "%";
        //lblRestProgressDesc.Content = "Row " + lineCount + " of " + totalRows;
        return null;
    }), null);
}

How can I resolve this exception? I have tried to run the garbage collector but I don’t think this affects the stack so it didn’t work and I have also tried adding a small delay to each line read but this doesn’t seem to have helped either.

  • 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-25T05:53:35+00:00Added an answer on May 25, 2026 at 5:53 am

    You shouldn’t need the window.Dispatcher.Invoke, as BackgroundWorker already marshals the calls to ProgressChanged back to its original SynchronizationContext. (This is assuming you’re starting the BW from the UI thread…)

    Try removing this, and just setting your values directly:

    void worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {
         progressRestore.IsIndeterminate = false;
         progressRestore.Value = e.ProgressPercentage;
         lblRestProgress.Content = e.ProgressPercentage + "%";
         //lblRestProgressDesc.Content = "Row " + lineCount + " of " + totalRows;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on the WPF project which involves creating a touch-screen application
I am currently working on a C# WPF project. I have a list which
I am currently working on a WPF application that processes data in a database
I am currently working on a project of mine which is a MSPaint-like WPF
Hy guys! I am currently working on a little WPF project using MVVM via
Currently working through a Teach Yourself WPF tutorial. Usually I can mentally convert from
I am currently working on a WPF/.Net project, In this project the user has
I am currently working on a wpf project in C#. I have a treeview
Im using pages in the WPF project that im currently working on. However i
i am currently working with SQL CE & WPF . in the middle of

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.