/// <summary> /// before processing the messages from queue /// </summary> /// <param name="queue">queue, its messages will be processed</param> /// <param name="cancel">to prevent this action set value to true, the default value is false</param> private void OnDoBeforeProccessMsgQueue(DDMsgQueue queue, ref bool cancel) { if (DoBeforeProccessMsgQueue != null) { DoBeforeProccessMsgQueue(queue, ref cancel); } }
/// <summary> /// function places an active non empty queue to the queue for processing /// </summary> private void ShiftActiveQueue() { if (activeMsgQueue.Count == 0) { return; // skip empty queue } lock (lockActiveMsgQueue) { lock (lockQueue4Processing) { queue4Processing.Enqueue(activeMsgQueue); // enqueue active queue } activeMsgQueue = new DDMsgQueue(); // init new active queue } }
/// <summary> /// Initialize Manager Message Queue with specified proccessing conditions /// </summary> /// <param name="conditions">proccessing conditions</param> public DDManagerMsgQueue(DDMsgFlushConditions conditions) { lock (lockActiveMsgQueue) { activeMsgQueue = new DDMsgQueue(); } lock (lockLostMsgQueue) { lostMsgQueue = new DDMsgQueue(); } lock (lockQueue4Processing) { queue4Processing = new Queue <DDMsgQueue>(); } this.conditions = conditions; SetTimerCondition(); SetTimerProccessMsg(); }
public virtual void Dispose() { lock (lockActiveMsgQueue) { lock (lockQueue4Processing) { // stop all timers timerProccessMsg.Stop(); timerCondition.Stop(); if (activeMsgQueue.Count != 0) { queue4Processing.Enqueue(activeMsgQueue); // enqueue active queue } activeMsgQueue = new DDMsgQueue(); // init new active queue } ProccessQueue(); } }