/// <summary> /// Attache les notifications d'annulation, Ils seront tous levés lors l'annulation de celle çi /// </summary> public void AttachNotifierCancellation(ProgressCancelNotifier iProgressCancelNotifier) { if (_attachedCancellationTokenSourceList == null) { _attachedCancellationTokenSourceList = new List <CancellationTokenSource>(); } _attachedCancellationTokenSourceList.Add(iProgressCancelNotifier.CancellationTokenSource); }
private static int ComputePercentage(ProgressCancelNotifier iNotifier) { var levelList = NotifierStateList.Where(x => x.Notifier.Guid == iNotifier.Guid).OrderBy(x => x.Level).ToList(); decimal previousRange = 100; decimal result = 0; //bouclage sur tous les niveaux foreach (var levelItem in levelList.Enum()) { var count = levelItem.ProgressCount; if (count == 0) { count = 1; } result += RecursivePercentage(previousRange, levelItem.ProgressCounter, count); previousRange = decimal.Divide(previousRange, count); } return((int)result); }
public SubLevel(ProgressCancelNotifier iNotifier, int iProgressCount, int iThreadCount) { lock (_notifierStateListLocker) { _notifier = iNotifier; var theLastState = NotifierStateList.Where(x => x.Notifier.Guid == iNotifier.Guid); int level = 1; if (theLastState.IsNotNullAndNotEmpty()) { level = theLastState.OrderByDescending(x => x.Level).First().Level + 1; } var newState = new NotifierState(); newState.Level = level; newState.Notifier = iNotifier; newState.ProgressCounter = 0; newState.ProgressCount = iProgressCount; newState.ThreadCount = iThreadCount; NotifierStateList.Add(newState); } }
/// <summary> /// Permet de créer une classe annulable /// </summary> public ProgressableCancellable(ProgressCancelNotifier iNotifier) { Notifier = iNotifier; }