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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:55:16+00:00 2026-06-14T08:55:16+00:00

Hi i have a program i created for my website i was trying to

  • 0

Hi i have a program i created for my website i was trying to update it so that the intense part of the code would run in a separate thread. The new thread creates several costume controls that i need to be placed inside of a container as a child control on the main GUI thread, but every time i run the code i get this error “The calling thread cannot access this object because a different thread owns it”. The debugger after throwing this error highlights the code part under [ if (FileStack.Dispatcher.CheckAccess()) ] Every time i run the code and the program attempts to invoke the control.
Here is my code

 public delegate void ADDFiLEHandel(FileControlxaml File);


 public void ADDFiles(FileControlxaml File)
      {

          if (FileStack.Dispatcher.CheckAccess())
          {
              FileStack.Children.Add(File);  //this is the code that gets height-lighted by the debugger 
          }
          else
          {
                      FileStack.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new ADDFiLEHandel(ADDFiles), File);

          }

Then i call the invoke like such from the new thread which i had to set the thread state to STA, What am i doing wrong Ive spent hours trying to get this to work.

    public void createfilethread(object data)
    {
    FileControlxaml  NewFile = new FileControlxaml();
    NewFile.Title = "Hellow World";
    ADDFiles(NewFile);
    }
  • 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-14T08:55:17+00:00Added an answer on June 14, 2026 at 8:55 am

    You cannot do this. When you instantiate DispatcherObjects in a thread that does not have an associated Dispatcher, a new dispatcher is created and associated to that thread. You cannot mix different UIElements created in different threads.

    Why would you create UIElements in a second thread? that’s what the “UI Thread” is meant for.

    Rethink your approach.

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

Sidebar

Related Questions

I have a program that I'm trying to distribute with py2app. When I run
Let's say I have created a program in C/C++ and have a source code.
I have created a non-form c# program that uses the NotifyIcon class. The text
HELP ! I'm trying to upgrade may program to support the new oAuth that
I am new to programming and I have been trying to create a program
I have been trying to compile the program on this website and got most
I have to refactor a Java program created with Eclipse RCP. My predecessor handed
I have created a program which allows me to upload images to my server.
I have created a program with Windows Forms in C# and the architecture is
I have created this simple program to learn shared_ptr using namespace std; #define Yes

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.