public virtual void Run()

in rd-net/RdFramework/Impl/RdSimpleDispatcher.cs [33:72]


    public virtual void Run()
    {
      while (myLifetime.IsAlive)
      {
        Action? nextTask = null;
        lock (myTasks)
        {
          if (myTasks.Count > 0)
            nextTask = myTasks.Dequeue();
        }

        if (nextTask != null)
        {
          try
          {
            myLogger.Trace(FormatLogMessage("Process incoming task"));
            nextTask();
          }
          catch (Exception e)
          {
            myLogger.Error(e, FormatLogMessage("Exception during task processing"));
          }
        }
        else
        {
          if (!myLifetime.IsAlive)
          {
            myLogger.Verbose(FormatLogMessage("Lifetime terminated. Exiting."));
            return;
          }

          var timeout = MessageTimeout == null || MessageTimeout == TimeSpan.MaxValue ? -1 : (int)MessageTimeout.Value.TotalMilliseconds;
          if (!myEvent.WaitOne(timeout))
          {
            throw new Exception($"Cannot receive a message in {timeout} ms");
          }
          myLogger.Trace(FormatLogMessage("Awakened"));
        }
      }
    }