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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:09:05+00:00 2026-05-23T07:09:05+00:00

I’ve got a problem with multi-threading – I am working on a framework which

  • 0

I’ve got a problem with multi-threading – I am working on a framework which includes two windows: A surfacwindow and a ordinary wpfwindow.

In my first test, the SurfaceWindow was automatically started, due to my visualstudio project choices and in the constructor of my Surface Window I have started the GUI.
One Thread for both Windows -> no problems 😉

Know I have to change the order, my starting point is a common .cs Class and I have difficulties with threading… The perfect solution for me would be to start first the SurfaceWindow and second the WPF-Window, but in the same Thread.

But I DON’T want the WPF-Window to be started in the Contructor of the SurfaceWindow, but the same effect!

Code which causes Threading-Problems:
(The calling thread can not access this object because the object is owned by another thread.)

 public Constructor()
    {

        Thread t = new Thread(new ThreadStart(StartSurfaceWIndowThread));
        t.SetApartmentState(ApartmentState.STA);
        t.Start();

        startWindow();

    }

    private void StartNewStaThread() {

        AdaptivePrototype.App app = new AdaptivePrototype.App();
        app.InitializeComponent();
        app.Run();

    }

    private void startWindow()
    {
            Thread thread = new Thread(() =>
            {
                WPFkGui w = new WPFGui(this);
                w.Show();

                System.Windows.Threading.Dispatcher.Run();
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();

    }

Now the Code which would be the perfect solution, but it doesn’t show the WPFGUI:

 public Constructor()
    {

        Thread t = new Thread(new ThreadStart(StartSurfaceWIndowThread));
        t.SetApartmentState(ApartmentState.STA);
        t.Start();

        startWindow();

    }

    private void StartNewStaThread() {

        AdaptivePrototype.App app = new AdaptivePrototype.App();
        app.InitializeComponent();
        app.Run();
    WPFkGui w = new WPFGui(this);
        w.Show();

    }

I would be happy about any help!
Thanks,
Chris

  • 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-23T07:09:05+00:00Added an answer on May 23, 2026 at 7:09 am

    I understand that you want 2 windows to show on startup and be able to interact with each other. No fancy threading code is needed.

    Open up your App.xaml file. There is an attrbibute in there for “StartupUri”. Remove that – this is basically a shortcut for telling WPF to show a specific window when the app starts up… you can skip this and code in your own startup behavior. To do so, next open up App.xaml.cs and insert something along the lines of:

            Window1 window1 = new Window1();
            Window2 window2 = new Window2(window1);
    
            window1.Show();
            window2.Show();
    

    This assumes of course that your window classes are named Window1 and Window2 and that you added a constructor to Window2 that takes an instance of Window1.

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

Sidebar

Related Questions

i got an object with contents of html markup in it, for example: string
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a JSP page retrieving data and when single or double quotes are
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string

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.