/// <summary> /// se deja de supervisar una instancia de MessageSupervisionResult /// </summary> /// <param name="result">Instancia de MessageSupervisionResult que se deja de supervisar</param> /// <returns></returns> public static bool EndSupervision(MessageSupervisionResult result) { if (result.IsCompleted) { return(false); } result.Syncro.WaitOne(); result.IsCompleted = true; result.Syncro.Set(); return(true); }
/// <summary> /// Inicia la supervision a un determinado mensaje, y /// </summary> /// <param name="message">Mensaje bajo supervision.</param> /// <param name="callback"></param> /// <param name="visits"></param> /// <returns></returns> public static MessageSupervisionResult Supervise(IMessage message, AsyncCallback callback, params TimeSpan[] visits) { var result = new MessageSupervisionResult(message) { Callback = callback }; result.Sequence.AddRange(visits); result.Sequence.Reverse(); Inquired(result); return(result); }
/// <summary> /// pasar al siguiente timer, anula el actual /// </summary> /// <param name="result"></param> public static bool Inquired(MessageSupervisionResult result) { if (result.IsCompleted) { return(false); } result.Syncro.WaitOne(); var span = result.Sequence[0]; result.Sequence.RemoveAt(0); TimerFactory.Schedule(OnTimeout, result, Convert.ToInt32(span.TotalMilliseconds)); result.Syncro.Set(); return(true); }