예제 #1
0
        private void ThreadProc()
        {
            Log.Instance.Write("Controller thread started");

            while (true)
            {
                try {
                    while (queue.Count < queueSize && cancel == false)
                    {
                        MultiControllerInstruction instruction = controller.GetInstruction();
                        lock (queue) {
                            queue.Enqueue(instruction);
                        }
                        evt.Set();
                        Thread.Sleep(0);
                    }
                    evt.WaitOne();
                }
                catch (ThreadAbortException) {
                    // ignore
                }
                catch (Exception ex) {
                    Log.Instance.Write("Exception on controller thread", ex);
                }
            }
        }
        public MultiControllerInstruction GetInstruction()
        {
            // this is the weirdest code i've ever written.
            MultiControllerInstruction instruction;

            if (peeks[index] != null)
            {
                instruction  = new MultiControllerInstruction(index, peeks[index]);
                peeks[index] = null;
            }
            else
            {
                peeks[index] = controllers[index].GetInstruction();
                if (peeks[index].longPause)
                {
                    index       = ++index % controllers.Count;
                    instruction = GetInstruction();
                }
                else
                {
                    instruction  = new MultiControllerInstruction(index, peeks[index]);
                    peeks[index] = null;
                }
            }
            return(instruction);
        }
 public MultiControllerInstruction GetInstruction()
 {
     // this is the weirdest code i've ever written.
     MultiControllerInstruction instruction;
     if (peeks[index] != null) {
         instruction = new MultiControllerInstruction(index, peeks[index]);
         peeks[index] = null;
     }
     else {
         peeks[index] = controllers[index].GetInstruction();
         if (peeks[index].longPause) {
             index = ++index % controllers.Count;
             instruction = GetInstruction();
         }
         else {
             instruction = new MultiControllerInstruction(index, peeks[index]);
             peeks[index] = null;
         }
     }
     return instruction;
 }
예제 #4
0
        private void ThreadProc()
        {
            Log.Instance.Write("Drawing thread started");

            // build the multicontroller
            IList <IController> controllers = new List <IController>();

            for (int i = 0; i < windows.Count; ++i)
            {
                controllers.Add(windows[i].Controller);
            }

            // begin the controller loop, aborted by stop call

            int cachesize = 20;

            Log.Instance.Write("Cache Size = " + Convert.ToString(cachesize));
            using (controller = new AsyncMultiController(new MultiController(controllers), cachesize)) {
                while (stopcall == false)
                {
                    try {
                        using (MultiControllerInstruction instruction = controller.GetInstruction()) {
                            instruction.screen = instruction.controllerIndex;
                            windows[instruction.controllerIndex].Draw(instruction);
                            Thread.Sleep(instruction.longPause ? config.LongInterval : config.ShortInterval);
                        }
                    }
                    catch (ThreadAbortException) {
                        // ignore
                    }
                    catch (Exception ex) {
                        Log.Instance.Write("Exception on drawing thread", ex);
                    }
                }
            }
            //stopped = true;
        }