Two Instances of the same App class
Posted: 06 Oct 2019, 19:52
As title implies: I'm trying to create two instances of the same app from one executable.
Basically i want 2 separate windows with the same view and put them on 2 monitors respectively.
The following code runs ok, but when uncommenting T.Start(), the error pops up: "An Application was already created"
I also changed the App class from examples as:
Basically i want 2 separate windows with the same view and put them on 2 monitors respectively.
The following code runs ok, but when uncommenting T.Start(), the error pops up: "An Application was already created"
Code: Select all
class Apper
{
static Thread T = null;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
T = new Thread(new ThreadStart(SecondWindow));
// T.Start();
App app = new App();
app.Run();
}
static void SecondWindow()
{
App app = new App(2);
app.Run();
}
}
Code: Select all
public partial class App : Application
{
public App()
{
Uri = "App.xaml";
}
public App(int WindowNumber)
{
Uri = "App.xaml";
}
protected override Display CreateDisplay()
{
return new Win32Display();
}
protected override RenderContext CreateRenderContext()
{
return new RenderContextD3D11();
}
protected override bool VSync => true;
}