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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:13:51+00:00 2026-05-27T17:13:51+00:00

I’m using a background-worker to do all of my processing. Inside there, I have

  • 0

I’m using a background-worker to do all of my processing. Inside there, I have many places where I write to my “log” text box. All of those work great, but at the end of the background-worker, the very last line, I have one more call via SynchronizationContext that doesn’t fire. Why do all of the other calls work, and not the last one?

I should add that the application just “hangs”, and there’s even an EventLog entry saying:

The program MVST.CodeSync.exe version 2.0.0.0 stopped interacting with Windows and was closed.
To see if more information about the problem is available, check the problem history in the Action Center control panel.
 Process ID: 1f5c
 Start Time: 01ccc0e2e7ca1d42
 Termination Time: 16
 Application Path: C:\Users\ganders\Desktop\NewCodeSync\MVST.CodeSync.exe
 Report Id: 629f3533-2cd6-11e1-9e15-005056b75254

Here’s the DoWork method (which is executed when calling RunWorkerAsync):

private void bgw_StartCompare(object sender, DoWorkEventArgs e)
{
    OnWriteLogArgs args = null;
    CompareData compareData = e.Argument as CompareData;

    // We need to iterate through all of the nodes and if they are checked, continue
    foreach (TreeNode subSystemNode in compareData.TreeNodes)
    {
        if (!subSystemNode.Checked)
            continue;

        args = new OnWriteLogArgs(String.Format("-------------------------- Comparing sub-system: \"{0}\" with CompareType: \"{1}\" --------------------------", subSystemNode.Text, compareData.CompareType));
        syncContext.Post(delegate { OnWriteLog(args); }, null);

        // Each of these nodes should be a server, so continue
        foreach (TreeNode serverNode in subSystemNode.Nodes)
        {
            if (!serverNode.Checked)
                continue;

            args = new OnWriteLogArgs(String.Format("-------------------------- Comparing server: \"{0}\" with CompareType: \"{1}\" --------------------------", serverNode.Text, compareData.CompareType));
            syncContext.Post(delegate { OnWriteLog(args); }, null);

            // The "tag" contains the server information that we need to do the comparison
            CustomConfig.Server server = (CustomConfig.Server)serverNode.Tag;

            if (!compareData.DoneInitialCompare)
                CompareAll(compareData, server, string.Empty, server.CompareBasePath, serverNode, compareData.CompareType);
            else
                CompareAllByTreeNode(compareData, server, serverNode, compareData.CompareType);
        }
    }

    syncContext.Post(delegate { OnWriteLog(new OnWriteLogArgs("Finished the compare...")); }, null);

    RebuildTreeViewArgs rArgs = new RebuildTreeViewArgs(compareData.OnlyShowDifferences, compareData.TreeNodes);
    syncContext.Post(delegate { OnRebuildTreeView(rArgs); }, null);

    MessageBox.Show("It made it...");

    syncContext.Post(delegate { OnWriteLog(new OnWriteLogArgs("Finished calling the rebuild tree view method...")); }, null);
}

You’ll notice at the end of the foreach loop, I do my write that says Finished the compare..., and that DOES write, but the next sync call:

     syncContext.Post(delegate { OnRebuildTreeView(rArgs); }, null);

Never gets executed. Here’s that method:

private void OnRebuildTreeView(RebuildTreeViewArgs args)
{
    syncContext.Post(delegate { OnWriteLog(new OnWriteLogArgs("Made it to the OnRebuildTreeView method...")); }, null);

    while (bgw.IsBusy)
    {
        syncContext.Post(delegate { OnWriteLog(new OnWriteLogArgs("Sleeping...")); }, null);
        Thread.Sleep(1000);
    }

    syncContext.Post(delegate { OnWriteLog(new OnWriteLogArgs("Starting the rebuild of the TreeView...")); }, null);

    TreeNode[] tn = args.NewStructure;

    tvSync.Nodes.Clear();

    foreach (TreeNode node in tn)
        tvSync.Nodes.Add(node);

    foreach (TreeNode node in tvSync.Nodes)
        FixCheckedAndUnCheckedNodes(node);

    ReloadTreeView(args.OnlyShowDifferences);
}
  • 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-27T17:13:52+00:00Added an answer on May 27, 2026 at 5:13 pm
    MessageBox.Show("It made it...");
    

    may also be causing problems. as this is expecting the UI thread, when in fact, your on a background thread

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

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

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.