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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:26:21+00:00 2026-06-16T23:26:21+00:00

I have this in my App.Xaml: public App() { _backgroundWorker = new BackgroundWorker(); _backgroundWorker.DoWork

  • 0

I have this in my App.Xaml:

public App()
{
    _backgroundWorker = new BackgroundWorker();
    _backgroundWorker.DoWork += new DoWorkEventHandler(DoBackgroundWork);
    _backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundCompleted);
    _backgroundWorker.RunWorkerAsync();

    _splashView = new SplashView();
    _splashView.Show();
}

The DoBackgroundWork method performs some database setup, and then the BackgroundCompleted event closes the _splashView and shows _mainView.

However, modifying anything in the _splashView from BackgroundCompleted causes a cross thread exception, which is what I though background workers were designed to fix. I’m guessing this has something to do with the way backgroundworker’s work in App.Xaml. Maybe this is a bad way to do a splash screen?

  • 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-16T23:26:22+00:00Added an answer on June 16, 2026 at 11:26 pm

    There is no guarantee which thread the event handler of OnWorkCompleted will be used for execution.

    See similar question BackgroundWorker OnWorkCompleted throws cross-thread exception

    You have to use the Invoke or BeginInvoke methods to modify visual elements from a background thread. You can call this directly on the object whose properties you are modifying or use the Dispatcher.

    EDIT: As per conversation with Adam

    The SynchronizationContext has the desired effect for the OnWorkCompleted event handler to be run on the initial thread (not the BackgroundWorker’s). http://msdn.microsoft.com/en-us/magazine/gg598924.aspx. (See Figure 2)

    If the BackgroundWorker is created and run prior to the SynchronizationContext initialization, then the OnWorkCompleted will execute on possibly the same thread as the BackgroundWorker.

    Thanks Adam.

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

Sidebar

Related Questions

I have this code: app = new Application(); app.Visible = false; workbook = app.Workbooks.Add(1);
In my usercontrol.xaml.cs. I have this dependency proprerty as bleow. public static readonly DependencyProperty
I have this simplified version of my app in XAML: <UserControl xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006
I have this problem that My WPF App in its MainWindow: public partial class
Let's say that I have a global variable defined in App.xaml.cs as follows: public
I have Silverlight class embedded into page, in App.xaml.cs this component registered to allow
I have this app (contacts style) in which you can add instances to a
So I have this app which needs to query entities from the Azure Tables
So I have this App in the store, and I would like to release
I have this code App.Model('users').find(function (err, users) { users.forEach(function(user) { console.log(user.username); }); }); //make

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.