Cambiado para kill oliviatasks
parent
640e58572b
commit
8e1ab00d3d
|
|
@ -89,7 +89,7 @@ namespace OliviaAddIn
|
|||
*/
|
||||
private bool lanza_geofoto()
|
||||
{
|
||||
Process pg;
|
||||
Process[] pg;
|
||||
string args;
|
||||
ProcessStartInfo pfi;
|
||||
|
||||
|
|
@ -109,10 +109,10 @@ namespace OliviaAddIn
|
|||
|
||||
//comprueba que haya arrancado geofoto
|
||||
//le da 2 seg de margen para que arranque
|
||||
pg = OliviaGlob.progr_eje.esta_geofoto(2, true);
|
||||
pg = OliviaGlob.progr_eje.is_process(OliviaDef.GeneralDef.NombGeofoto, 2, true);
|
||||
if (pg == null)
|
||||
{
|
||||
MessageBox.Show("No está Geofot, args= "+args, "Olivia", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("No está Geofoto, args= "+args, "Olivia", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -598,13 +598,13 @@ namespace OliviaAddIn
|
|||
}
|
||||
|
||||
/**
|
||||
* Itera para comprobar que ha arrancado bien geofoto
|
||||
* Itera para comprobar que ha arrancado bien un proceso, o ver si está arrancado
|
||||
* int t_max : seg espera
|
||||
* bool espera_start : si true, se quiere esperar t_max a que arranque,
|
||||
* si false, se quiere esperar a que se cierre
|
||||
* Devuelve el proceso si está, para cancelarlo, y null si no está
|
||||
*/
|
||||
public Process esta_geofoto(int t_max, bool espera_start)
|
||||
public Process[] is_process(string nombproc, int t_max, bool espera_start)
|
||||
{
|
||||
bool esta_geo = !espera_start;
|
||||
int veces = 0;
|
||||
|
|
@ -627,7 +627,7 @@ namespace OliviaAddIn
|
|||
{
|
||||
try
|
||||
{
|
||||
pg = Process.GetProcessesByName("geofoto");
|
||||
pg = Process.GetProcessesByName(nombproc);
|
||||
if (pg.Length == 0)
|
||||
esta_geo = false;
|
||||
else
|
||||
|
|
@ -646,7 +646,7 @@ namespace OliviaAddIn
|
|||
}
|
||||
|
||||
if (esta_geo)
|
||||
return pg[0];
|
||||
return pg;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
|
@ -655,13 +655,13 @@ namespace OliviaAddIn
|
|||
* Comprueba si geofoto ha salido y le espera durante T seg. Si no, para la tarea
|
||||
* return true si ha terminado, false si no
|
||||
*/
|
||||
private bool espera_geofoto()
|
||||
private bool espera_process(string nombproc)
|
||||
{
|
||||
bool esta_geo = true;
|
||||
Process pg;
|
||||
Process[] pg;
|
||||
|
||||
//le da 3 seg de margen para que se cierre
|
||||
pg = esta_geofoto(2, false);
|
||||
pg = is_process(nombproc, 2, false);
|
||||
esta_geo = (pg != null);
|
||||
|
||||
if (esta_geo)
|
||||
|
|
@ -669,9 +669,12 @@ namespace OliviaAddIn
|
|||
//mata a la fuerza la tarea
|
||||
try
|
||||
{
|
||||
pg.Kill();
|
||||
if (pg.WaitForExit(1000))
|
||||
esta_geo = false;
|
||||
for (int i = 0; i < pg.Length; i++)
|
||||
{
|
||||
pg[i].Kill();
|
||||
if (pg[i].WaitForExit(500))
|
||||
esta_geo = false;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
|
@ -679,7 +682,6 @@ namespace OliviaAddIn
|
|||
}
|
||||
}
|
||||
return !esta_geo;
|
||||
|
||||
}
|
||||
|
||||
//*************************************************************************************
|
||||
|
|
@ -691,11 +693,12 @@ namespace OliviaAddIn
|
|||
{
|
||||
//ha terminado el thread, continua cerrando
|
||||
fin_thr();
|
||||
if (!espera_geofoto())
|
||||
if (!espera_process(OliviaDef.GeneralDef.NombGeofoto))
|
||||
{
|
||||
//no ha podido cerrarlo
|
||||
MessageBox.Show("No se ha podido cerrar GeoFoto", "Olivia", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
espera_process(OliviaDef.GeneralDef.NombOlvTasks);
|
||||
e.Cancel = false;
|
||||
Hide();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ namespace OliviaDef
|
|||
public const string EjecGeoParamSep = "/";
|
||||
public const string EjecGeoProgName = "olivia";
|
||||
public const string EjecGeoParamIgual = ":";
|
||||
public const string NombGeofoto = "geofoto";
|
||||
public const string NombOlvTasks = "OliviaTasks";
|
||||
/**
|
||||
* Define el nombre del grupo de propiedades generales
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue