Ejemplo n.º 1
0
 public void Deliver(byte[] message)
 {
     if (_currentStatus.IsNotRunning())
     {
         Logger.Log(Level.Warning, string.Format(CultureInfo.InvariantCulture, "Trying to send a message to an task that is in {0} state. Ignored.", _currentStatus.State));
         return;
     }
     try
     {
         OnNext(new DriverMessageImpl(message));
     }
     catch (Exception e)
     {
         Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, "Error during message delivery.", Logger);
         _currentStatus.SetException(
             TaskClientCodeException.Create(TaskId, ContextId, "Error during message delivery.", e));
     }
 }
Ejemplo n.º 2
0
        public void Suspend(byte[] message)
        {
            Logger.Log(Level.Info, string.Format(CultureInfo.InvariantCulture, "Trying to suspend Task {0}", TaskId));

            if (_currentStatus.IsNotRunning())
            {
                Logger.Log(Level.Warning, string.Format(CultureInfo.InvariantCulture, "Trying to suspend an task that is in {0} state. Ignored.", _currentStatus.State));
                return;
            }
            try
            {
                OnNext(new SuspendEventImpl(message));
                _currentStatus.SetSuspendRequested();
            }
            catch (Exception e)
            {
                Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, "Error during Suspend.", Logger);
                _currentStatus.SetException(
                    TaskClientCodeException.Create(TaskId, ContextId, "Error during Suspend().", e));
            }
        }