Beispiel #1
0
 private void backgroundWorker_DoServerWork(object sender, DoWorkEventArgs e)
 {
     BackgroundWorker worker = sender as BackgroundWorker;
     System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Lowest;
     Monitor.EndAddNewObject();
     while (theEnd != true)
     {
         if (Monitor.CheckQueue() == false)
         {
             System.Threading.Thread.Sleep(100);
             Monitor.ReportServer(0, 0);
         }
         else
         {
             Request rqst = new Request();
            // System.Threading.Thread.Sleep(500);
             System.Threading.Thread.Sleep(2000);
             rqst = Monitor.SolutionRequest();
             Monitor.ReportServer(1, rqst.task);
             worker.ReportProgress(10);
             Monitor.SendResult(rqst.n, rqst.task + 49517537);
             //worker.ReportProgress(20);
         }
             //
     }
 }
Beispiel #2
0
        public static void SendRequest(int n, int task)
        {
            lock (lck) {
            events[n].Reset();
            Request rqst = new Request();
            rqst.n = n;
            rqst.task = task;
            queue.Add(rqst);
            ClientInfo stt = new ClientInfo();
            stt.status = "ожидание ответа";
            stt.time = DateTime.Now;
            stt.requestCount = statuses[n].requestCount + 1;
            stt.lastTask = task;

            statuses[n] = stt;
              }
        }
Beispiel #3
0
        public static Request SolutionRequest()
        {
            int key;
              int val;
              lock (lck) {
            key = queue.First().n;
            val = queue.First().task;
            //queue.Remove(queue.First());

              }
              Request rqst = new Request();
              rqst.n = key;
              rqst.task = val;
              return rqst;
        }
Beispiel #4
0
        public static void ReportServer(int status, int task)
        {
            lock (lck) {
            Request rqst = new Request();
            rqst.n = status;
            rqst.task = task;

            serverStat.Add(rqst);
              }
        }