コード例 #1
0
ファイル: BGCurve.cs プロジェクト: Pau5erra/classe-IA
 //------------------------------ batch handling (to avoid event firing for every operation). 
 /// <summary>
 /// Executes a batch operation.
 /// During batch operation events firing will be suppressed, and event will be fired only after TransactionCommit is invoked.
 /// it is for event handling only .
 /// </summary>
 public void Transaction(Action action)
 {
     FireBeforeChange("Changes in transaction");
     transactionLevel++;
     if (UseEventsArgs && transactionLevel == 1) ChangeList.Clear();
     try
     {
         action();
     }
     finally
     {
         transactionLevel--;
         if (transactionLevel == 0)
         {
             FireChange(UseEventsArgs ? new BGCurveChangedArgs(this, ChangeList.ToArray()) : null);
             if (UseEventsArgs) ChangeList.Clear();
         }
     }
 }