0
這裏我使用c#.net窗口服務,記錄是躺在數據庫中的一個特定的列作爲null這些記錄它將獲取它將創建一個文本文件並且它將狀態更新爲FG,而當我在該實例中啓動服務時,如果任何狀態爲null的記錄正確生成並更新,則在另一實例中,如果假設新記錄進入數據庫,則此線程無法啓動if我們wantedly做重新啓動該服務意味着它正在採取現有的記錄,如何解決這個問題,可以在任何一個指導我請問題發生在線程在不同的情況下,通過使用c#.net
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew)) // Transaction Scope Started
{
try
{
if (threadCTD == null)
{
threadCTD = new Thread(new ThreadStart(FileGenerationForCTD)); // Thread Initialize for CTD
DataSet samdsCTD = new DataSet();
DataAccessLayer objDbAccessCTD = new DataAccessLayer();
samdsCTD = objDbAccessCTD.getFilesFromDataBase(strSelectProcedureName, "ECD");
if (samdsCTD.Tables[0].Rows.Count > 0 && samdsCTD.Tables[1].Rows.Count > 0)
{
samdsCTD.Dispose();
if ((threadCTD == null) || (threadCTD.ThreadState == System.Threading.ThreadState.Stopped) || (threadCTD.ThreadState == System.Threading.ThreadState.Unstarted) || (threadCTD.ThreadState == System.Threading.ThreadState.Aborted))
threadCTD.Start(); // Thread Started for ITD
}
samdsCTD.Dispose();
}
}
catch (Exception ex){}
finally
{
scope.Complete();
}
}
如果你可以在發佈之前清理你的代碼,它會非常有幫助 - 縮進它會更加理智,所以我們可以看到相關的位,擺脫註釋掉的行等。請參見http://tinyurl.com/so-hints – 2012-02-20 12:59:42
@jon雙向飛視按要求我已經做了相同的 – shannu 2012-02-20 13:05:57
不是真的 - 看看所有的空白行和意圖是*方式*超過它的需要。 – 2012-02-20 13:12:46