Hi Guys,
So I have created an application that has a custom OnStartUp event handler.
The code within which is similar to this:
m_ConfigurationManager = ConfigurationManager.InitializeInstance(Assembly.GetExecutingAssembly().GetName().Name,
Code.StringToSecureString());
if (m_ConfigurationManager.Instance.ReadConfiguration() == false)
{
Wizard dlg = new Wizard("Application Name");
if (dlg.ShowDialog() == true)
{
m_ConfigurationManager.Configuration = dlg.Result;
if (m_ConfigurationManager.Instance.Configuration.VerifyData(Code))
m_ConfigurationManager.Instance.Configuration.SecureData();
m_ConfigurationManager.SaveConfiguration();
}
else
{
Current.Shutdown();
}
}
if (!m_ConfigurationManager.Instance.ReadConfiguration()) Current.Shutdown();
MainWindow mainWindow = new MainWindow();
mainWindow.Show();
Now the problem I have is this, if my configuration wizard launches and is completed succesffuly instead of the last sections of code:
if (!m_ConfigurationManager.Instance.ReadConfiguration()) Current.Shutdown();
MainWindow mainWindow = new MainWindow();
mainWindow.Show();
runs through, but the application just terminates instead of showing the mainWindow. My understanding is that this is because the message pump is shut down. Is there any what I can stop this from happening?
I have tried calling "Application.Run(new MainWindow)" but this won't compile. I have also tried "this.Run(new MainWindow)" and this results in a dispatch error. (suggested from
http://stackoverflow.com/[
^])
Has anyone got any idea how I can keep the program running after the wizard closes and run the main window?
App.Xaml Code:
<application x:class="ApplicationName.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" startup="App_OnStartup">
<application.resources>
</application.resources>
</application>