在这里,我想解释一下,如果在A工作完成后,A工作将不去B工作,那么A工作就会长期进行下去,那么现在如何工作,但这里的要求是,所有工作都应启动,但没有任何工作受到侵扰,从而无法改变这种read。
protected override void OnStart(string[] args)
{
strNowDate = DateTime.Now.ToLongTimeString();
timerjob.Elapsed += new ElapsedEventHandler(CsvGenFromDatabase);
timerjob.Interval = Convert.ToDouble(DueTime);
timerjob.Enabled = true;
eventLog1.WriteEntry("my service started");
}
protected override void OnStop()
{
strNowDate = DateTime.Now.ToLongTimeString();
eventLog1.WriteEntry("my service stopped");
}
private void CsvGenFromDatabase(object sender, EventArgs e)
{
timerjob.stop();
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew)) // Transaction Scope Started
{
Thread threadITD = new Thread(new ThreadStart(FileGenerationForITD)); // Thread Initialize for ITD
Thread threadCTD = new Thread(new ThreadStart(FileGenerationForCTD)); // Thread Initialize for CTD
Thread threadCID = new Thread(new ThreadStart(FileGenerationForCID)); // Thread Initialize for CID
Thread threadFFM = new Thread(new ThreadStart(FileGenerationForFFM)); // Thread Initialize for FFM
try
{
if ((threadITD == null) ||
(threadITD.ThreadState == System.Threading.ThreadState.Stopped) ||
(threadITD.ThreadState == System.Threading.ThreadState.Unstarted))
{
threadITD.Start(); // Thread Started for ITD
}
if ((threadCTD == null) ||
(threadCTD.ThreadState == System.Threading.ThreadState.Stopped) ||
(threadCTD.ThreadState == System.Threading.ThreadState.Unstarted))
{
threadCTD.Start(); // Thread Started for CTD
}
if ((threadCID == null) ||
(threadCID.ThreadState == System.Threading.ThreadState.Stopped) ||
(threadCID.ThreadState == System.Threading.ThreadState.Unstarted))
{
threadCID.Start(); // Thread Started for CID
}
if ((threadFFM == null) ||
(threadFFM.ThreadState == System.Threading.ThreadState.Stopped) ||
(threadFFM.ThreadState == System.Threading.ThreadState.Unstarted))
{
threadFFM.Start(); // Thread Started for FFM
}
}
catch (Exception ex)
{
objErrorLog.SrtErrorText = ex.ToString().Substring(0, 25);
objErrorLog.StrErrorDescription = ex.ToString();
objErrorLog.WriteErrorLog(objErrorLog);
}
finally
{
scope.Complete();
}
}
timerjob.start();
}