Evitar el arranque varias veces

20/10/2006 - 17:05 por Jorge A. Forti A. | Informe spam
Saludos al grupo
Como evito que el usuario arranque mas de 1 vez la misma aplicacion
Uso C#

Gracias de antemanos
 

Leer las respuestas

#1 Bela Istok
20/10/2006 - 18:54 | Informe spam
Yo utilizo algo como esto (estoy seguro que hay mejores maneras ;)

private static bool IsRunning
{
get
{
// Determine if there is an instance of the app running
try
{

Process[] procList = Process.GetProcesses();
if (procList != null)
{
int count = 0;
Assembly ass = Assembly.GetExecutingAssembly();
string name = ass.GetName().Name + ".exe";
for (int i = procList.Length - 1; i >= 0; i--)
{
if (procList[i].ProcessName == name && count >
1)
{
count++;
}
}

// If found more than one time
if (count > 1)
return true;
}
}
catch (Exception ex)
{
}
return false;
}
}

public void Main()
{
// Check if other instance is running
if (IsRunning)
{
// Here show a message to the user.
return;
}
// Here the application code.
}
"Jorge A. Forti A." wrote in message
news:
Saludos al grupo
Como evito que el usuario arranque mas de 1 vez la misma aplicacion
Uso C#

Gracias de antemanos

Preguntas similares