Beispiel #1
0
 /// <summary>
 /// Makes sure the block is completed if it should be.
 /// </summary>
 protected virtual void VerifyCompleteness()
 {
     if (MessageQueue.IsCompleted && externalCompleteTester())
     {
         CompHelper.Complete();
     }
 }
Beispiel #2
0
 public Startup(IConfiguration configuration)
 {
     Configuration = configuration;
     //DBCenter.DB = SqlBase.CreateHelper("mysql");
     //DBCenter.DB.ConnectionString = "server=localhost;database=zoomlacms;uid=root;pwd=111111aa;SslMode=None;";
     CompHelper.Startup();
     DBCenter.DB = SqlBase.CreateHelper("mssql");
     DBCenter.DB.ConnectionString = SiteConfig.SiteInfo.ConnectionString;
 }
Beispiel #3
0
        /// <summary>
        /// Handles asynchronously finished Task, continues processing the queue.
        /// </summary>
        void TaskFinished(TTask task)
        {
            if (task.IsFaulted)
            {
                CompHelper.RequestFault(task.Exception, false);
                FinishProcessQueue();
                return;
            }

            if (processFinishedTask != null)
            {
                processFinishedTask(task);
            }

            ProcessQueueWithoutStart();
        }
        /// <summary>
        /// Processes the input queue of the block.
        /// </summary>
        protected override void ProcessQueue()
        {
            StartProcessQueue();

            try {
                int i = 0;
                while (CanRun(i))
                {
                    if (!processItem())
                    {
                        break;
                    }
                    i++;
                }
            } catch (Exception e) {
                CompHelper.RequestFault(e, false);
            }

            FinishProcessQueue();
        }
Beispiel #5
0
        /// <summary>
        /// The part of <see cref="ProcessQueue"/> specific to asynchronous execution.
        /// Handles scheduling continuation on the Task returned by the block's action
        /// (or continuing synchrnously if possible).
        /// </summary>
        void ProcessQueueWithoutStart()
        {
            // catch is needed here, if the Task-returning delegate throws exception itself
            try {
                int i = 0;
                while (CanRun(i))
                {
                    TTask task;
                    if (!processItem(out task))
                    {
                        break;
                    }
                    if (task == null || task.IsCanceled ||
                        (task.IsCompleted && !task.IsFaulted))
                    {
                        if (processFinishedTask != null)
                        {
                            processFinishedTask(task);
                        }
                    }
                    else if (task.IsFaulted)
                    {
                        CompHelper.RequestFault(task.Exception, false);
                        break;
                    }
                    else
                    {
                        task.ContinueWith(
                            t => TaskFinished((TTask)t), Options.TaskScheduler);
                        return;
                    }
                    i++;
                }
            } catch (Exception e) {
                CompHelper.RequestFault(e, false);
            }

            FinishProcessQueue();
        }