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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:57:18+00:00 2026-05-25T02:57:18+00:00

I have large application which is not designed well. In particular on start it

  • 0

I have large application which is not designed well. In particular on start it is initializing many services in the UI thread. The problem is that initialization could be time-consuming, so UI thread is freezing in the meantime. I can’t move it to background thread as some services relies on which thread they started and there’s simply too many code to check where it happens line-by-line.

The idea is to show loading screen with ProgressBar in separate thread with separate Dispatcher:

ThreadStart initLoadingDialog = () =>
                                    {
                                        _currentDispatcher = Dispatcher.CurrentDispatcher;
                                        _dialogWindow = new MyDialogWindow();
                                        _dialogWindow.Show();
                                        Dispatcher.Run();
                                    };
var thread = new Thread(initLoadingDialog);
thread.SetApartmentState(ApartmentState.STA);
thread.Start();

(Well, code is not exactly precise because I use MVVM and there’s no MyDialogWindowClass but rather just Window with Contents set to ViewModel and DataTemplate in resources. But it is not important ASAIK here).

It works, but seems uses some resources, thus effectively binding them to non-main-UI thread. And later I receive exception “Cannot convert the value in attribute ‘Background’ to object of type ‘System.Windows.Media.Brush’. The calling thread cannot access this object because a different thread owns it. Error at object ‘System.Windows.Controls.Border’ in markup file ‘PresentationFramework.Aero, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/aero.normalcolor.xaml’.”

Well, what I want to is isolate this single dialog totally, so that it will have its own resources (in fact there’s just Grid with ProgressBar and two TextBlocks on it) and not use anything else. Is there a way to do this?

P.S. Or maybe someone knows how to determine which Brush resource exactly is in question? Because I only have this exception and nothing else… what is the source of the problem really?

UPD: It is ProgressBar. Its style uses some non-frozen brush and it binds to the thread.

  • 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-25T02:57:18+00:00Added an answer on May 25, 2026 at 2:57 am

    I’m guessing that the brush that’s causing you a problem was instantiated at an earlier time on the main UI thread and that’s why your seeing your error. I think you might have to override the control templates of all the controls in your dialog and make sure that you freeze all the brushes.

    Something like this:

    <LinearGradientBrush freezable:Freeze="True" 
    xmlns:freezable="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" 
    />
    

    Also, I believe that the dispatcher will continue to run after your window closes. You need to manually shut it down.. something like this:

    _dialogWindow.Closed += (sender, e) => _dialogWindow.Dispatcher.InvokeShutdown();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Flex application that calls a function which searches a large document
We have large C# application spanning many projects which is packaged into an .MSI
I have a large application which Just afew Pages of that uses ViewState. I
The Problem We have a large web application that stores and displays sensitive HIPAA-related
We have fairly large C++ application which is composed of about 60 projects in
We have a large (about 580,000 loc) application which in Delphi 2006 builds (on
I'm looking at building a Rails application which will have some pretty large tables
I'm designing an application which will have a network interface for feeding out large
We have a rather large and complex application written in Java which is running
I have a large application that uses EJB 2.x entity beans (BMP). This is

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.