Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » Queue

Public general use code classes and xml files that we've compiled and used over the years:

Queue Support class.

   1:  using System;
   2:  using System.Web;
   3:  using System.Xml;
   4:  using System.Configuration;
   5:  using System.Data;
   6:  using System.Collections;
   7:  using System.Collections.Generic;
   8:  using System.Text;
   9:  using System.Text.RegularExpressions;
  10:  using System.IO;
  11:  using System.Xml.Linq;
  12:  using System.Deployment;
  13:   
  14:  namespace Ia.Cl.Model.Db
  15:  {
  16:      ////////////////////////////////////////////////////////////////////////////
  17:   
  18:      /// <summary publish="true">
  19:      /// Queue Support class.
  20:      /// </summary>
  21:      /// <remarks> 
  22:      /// Copyright © 2015-2016 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  23:      ///
  24:      /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
  25:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  26:      ///
  27:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  28:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  29:      /// 
  30:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  31:      /// 
  32:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  33:      /// </remarks> 
  34:   
  35:      ////////////////////////////////////////////////////////////////////////////
  36:   
  37:      /// <summary>
  38:      ///
  39:      /// </summary>
  40:      public static class Queue
  41:      {
  42:          private static Dictionary<string, System.Collections.Generic.Queue<string>> queueDictionary = new Dictionary<string, System.Collections.Generic.Queue<string>>();
  43:   
  44:          ////////////////////////////////////////////////////////////////////////////
  45:   
  46:          /// <summary>
  47:          ///
  48:          /// </summary>
  49:          public static void Enqueue(string queueName, string value)
  50:          {
  51:              System.Collections.Generic.Queue<string> q;
  52:   
  53:              if (!string.IsNullOrEmpty(queueName))
  54:              {
  55:                  if (!queueDictionary.ContainsKey(queueName))
  56:                  {
  57:                      q = new Queue<string>();
  58:   
  59:                      queueDictionary[queueName] = q;
  60:                  }
  61:   
  62:                  queueDictionary[queueName].Enqueue(value);
  63:              }
  64:          }
  65:   
  66:          ////////////////////////////////////////////////////////////////////////////
  67:   
  68:          /// <summary>
  69:          ///
  70:          /// </summary>
  71:          public static string Dequeue(string queueName)
  72:          {
  73:              string value;
  74:              //System.Collections.Generic.Queue<string> q;
  75:   
  76:              value = null;
  77:   
  78:              if (!string.IsNullOrEmpty(queueName))
  79:              {
  80:                  if (queueDictionary.ContainsKey(queueName))
  81:                  {
  82:                      value = queueDictionary[queueName].Dequeue();
  83:                  }
  84:              }
  85:   
  86:              return value;
  87:          }
  88:   
  89:          ////////////////////////////////////////////////////////////////////////////
  90:   
  91:          /// <summary>
  92:          ///
  93:          /// </summary>
  94:          public static int Count(string queueName)
  95:          {
  96:              int c;
  97:              //System.Collections.Generic.Queue<string> q;
  98:   
  99:              c = 0;
 100:   
 101:              if (!string.IsNullOrEmpty(queueName))
 102:              {
 103:                  if (queueDictionary.ContainsKey(queueName))
 104:                  {
 105:                      c = queueDictionary[queueName].Count;
 106:                  }
 107:              }
 108:   
 109:              return c;
 110:          }
 111:   
 112:          ////////////////////////////////////////////////////////////////////////////
 113:          ////////////////////////////////////////////////////////////////////////////
 114:      }
 115:   
 116:      ////////////////////////////////////////////////////////////////////////////
 117:      ////////////////////////////////////////////////////////////////////////////
 118:  }
 119: