mercredi 11 mars 2015

try to Perform reset to my program But without success

i try to Perform reset to my C# program like this:



System.Windows.Forms.Application.Restart();


also i have in the Program class this To ensure that there is only one instance



[STAThread]
static void Main()
{
if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
{
MessageBox.Show("the program is runing", "attention", 0, MessageBoxIcon.Hand);
return;
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());

}
}


The problem that when I run the program and Perform reset



System.Windows.Forms.Application.Restart();


i got message that the program is running Or nothing happens at all.


thanks


Aucun commentaire:

Enregistrer un commentaire