Beispiel #1
0
 public void SendRequest(Stopper stop)
 {
     if (pt != null)
     {
         pt.addRequest(stop);
     }
 }
Beispiel #2
0
 private void Close(object obj)
 {
     Stopper.changeAllStop();
     if (pt != null)
     {
         pt.Dispose();
     }
     if (ctl != null)
     {
         for (int i = 0; i < CountConsumerThread; i++)
         {
             ctl[i].Dispose();
         }
     }
 }
Beispiel #3
0
        /* Function from the task specification*/
        public static void ProcessRequest(Request request, Stopper stopSignal)
        {
            Random rnd   = new Random(3000);
            int    value = rnd.Next();
            int    i     = 0;

            while (i <= value)
            {
                i++;
                if (stopSignal.IsStop)
                {
                    break;
                }
                Thread.Sleep(1);
            }
        }
Beispiel #4
0
        public static Request GetRequest(Stopper stopSignal)
        {
            Random rnd   = new Random(3000);
            int    value = rnd.Next();
            int    i     = 0;

            while (i <= value)
            {
                i++;
                if (stopSignal.IsStop)
                {
                    break;
                }
                Thread.Sleep(1);
            }
            return(stopSignal.IsStop ? null : (new Request()));
        }
Beispiel #5
0
 private override void Run()
 {
     while (doing)
     {
         Request request = null;
         Stopper stop    = null;
         if (QueueStop.CountQueue() != 0)
         {
             stop    = QueueStop.RemoveQueue();
             request = Request.GetRequest(stop);
         }
         else
         {
             Thread.Sleep(5000);
         }
         if (request != null && stop != null)
         {
             QueueCommon.AddQueue(new Element(stop, request));
         }
     }
 }
Beispiel #6
0
 public void addRequest(Stopper stop)
 {
     QueueStop.AddQueue(stop);
 }
Beispiel #7
0
 public Element(Stopper _stopSignal, Request _request)
 {
     this.stopSignal = _stopSignal;
     this.request    = _request;
 }