M
mp
I start a service and I have the following code:
//This code is Service2
if(Directory.Exists(pathFinal) && Directory.Exists(PathIntermediate))
{
m_threadFinal = new Thread(new System.Threading.ThreadStart(BuildFile));
m_threadFinal.Start();
}
private void BuildFile()
{
//all code works here
//Then when I am done I want to stop my service and restart another
service
DoThe magic();
}
Private void DoTheMagic()
{
//want to stop service2 itself and restart service1
try
{
ServiceController scStop = new ServiceController("service2");
ServiceRunning=false;
scStop.Stop();
scStop.Close();
ServiceController sc1 = new ServiceController("service1");
if (sc1.Status.Equals(ServiceControllerStatus.Stopped))
{
sc1.Start();
}
}
catch(Exception ex)
{
System.Diagnostics.EventLog.WriteEntry("error" + ex.Message ,
System.Diagnostics.EventLogEntryType.Error);
}
}
I do a Net Stop "service1" which works fine
then I do a Net Start "service2" , actually these are in bat files.
This works if i set schedule and run them manually , but If i wait for it to
run the next day, service2 does not stop!!!!!!!!!!!!!!! so weired!!!! can
anyone help???
Thanks
//This code is Service2
if(Directory.Exists(pathFinal) && Directory.Exists(PathIntermediate))
{
m_threadFinal = new Thread(new System.Threading.ThreadStart(BuildFile));
m_threadFinal.Start();
}
private void BuildFile()
{
//all code works here
//Then when I am done I want to stop my service and restart another
service
DoThe magic();
}
Private void DoTheMagic()
{
//want to stop service2 itself and restart service1
try
{
ServiceController scStop = new ServiceController("service2");
ServiceRunning=false;
scStop.Stop();
scStop.Close();
ServiceController sc1 = new ServiceController("service1");
if (sc1.Status.Equals(ServiceControllerStatus.Stopped))
{
sc1.Start();
}
}
catch(Exception ex)
{
System.Diagnostics.EventLog.WriteEntry("error" + ex.Message ,
System.Diagnostics.EventLogEntryType.Error);
}
}
I do a Net Stop "service1" which works fine
then I do a Net Start "service2" , actually these are in bat files.
This works if i set schedule and run them manually , but If i wait for it to
run the next day, service2 does not stop!!!!!!!!!!!!!!! so weired!!!! can
anyone help???
Thanks