/// <summary> /// Makes sure the block is completed if it should be. /// </summary> protected virtual void VerifyCompleteness() { if (MessageQueue.IsCompleted && externalCompleteTester()) { CompHelper.Complete(); } }
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; }
/// <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(); }
/// <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(); }