0
我有以下任務來完成:執行數據庫塊querys
在我的程序有數據庫querys或問題的塊。 我想執行這些問題,並等待所有問題的結果,或者如果一個問題失敗,就會發現錯誤!
我的問題物體看起來像這樣(簡化):
public class DbQuestion(String sql)
{
[...]
}
[...]
//The answer is just a holder for custom data...
public void SetAnswer(DbAnswer answer)
{
//Store the answer in the question and fire a event to the listeners
this.OnAnswered(EventArgs.Empty);
}
[...]
public void SetError()
{
//Signal an Error in this query!
this.OnError(EventArgs.Empty);
}
因此被炒到數據庫中每一個問題都有等待解析結果的監聽器。
現在我要火一些問題異步的數據庫(最多5個左右)和火的所有疑問或數據的情況下生成錯誤,如果只有一個問題拋出一個!
哪個是最好的還是來完成這一任務的好辦法? 我可以真正執行多個並行的問題嗎?當一個問題拋出錯誤時,我可以停止所有的工作嗎?
我想我需要這方面的一些靈感...
剛一說明:I'm使用.NET框架2.0的工作
嘗試則ExecuteBatch()。這可能是有用的http://www.codeproject.com/Articles/306722/Executing-multiple-SQL-statements-as-one-against-S –