mercredi 11 mars 2015

WinForm c#: Check first run and show message

I am creating a winform application containing first run check. I've been following these 2 articles:



First run check is supposed to check if application has ever been run and if not, it should show some message to the user. Problem i am having is, that this message is displayed before winform application is initialized/displayed and I am not able to find out why. Here is my code:


Program.cs



public static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}


Form1.cs



public Form1()
{
this.InitializeComponent();
CheckFirstRun();
}

private static void CheckFirstRun()
{
if(Settings.Default.FirstRun)
{
MessageBox.Show(
"First run");
Settings.Default.FirstRun = false;
Settings.Default.Save();
}


It shows Message box with msg: "First run" and after clicking OK button it shows WinForm. What I am trying to achieve is to Display WinForm first and if it is first run then show this msgBox.


Any ideas?


Aucun commentaire:

Enregistrer un commentaire