I currently have a project that starts up a central logic class (which uses some other .dll's to check on hardware or connect to the database). After that, a WPF form is started. This form uses the information of the central logic.
Currently, the application is being started like this:
public void StartTheWholeBunch()
{
Thread thread = new Thread(() =>
{
applicationLogic = new ApplicationLogic();
Application app = new Application();
app.Run(new MainWindow(applicationLogic));
});
thread.IsBackground = true;
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
}
The MainWindow is one of the two WPF applications I want to use. So a second one will join in the fun o a later stage.
The current setup is working. Everything communicates with each other and stuff, no problems here. I was just wondering if the use of this Thread
is correct. When I leave applicationLogic = new ApplicationLogic();
out of the Thread, things are bound to go wrong (for example with creating MessageBox popups, the whole application will freeze here).
Should I keep everything in one thread here? Or is it a better practice to split everything up and/or create a Threadpool? How can I approach that the best way?