Пример #1
0
        public frmThreadRace()
        {
            InitializeComponent();

            //init brush colours
            pnlThread1.ProgressColour = System.Drawing.Brushes.Red;
            pnlThread2.ProgressColour = System.Drawing.Brushes.Green;
            pnlThread3.ProgressColour = System.Drawing.Brushes.Blue;

            //init progress generator seeded with number of preference
            m_pg = new ProgressGenerator(5);

            //init progress threads
            m_pt1 = new ProgressThread(ref pnlThread1, ref m_pg);
            m_pt2 = new ProgressThread(ref pnlThread2, ref m_pg);
            m_pt3 = new ProgressThread(ref pnlThread3, ref m_pg);

            m_t1 = new Thread(new ThreadStart(m_pt1.IncrementProgress));
            m_t2 = new Thread(new ThreadStart(m_pt2.IncrementProgress));
            m_t3 = new Thread(new ThreadStart(m_pt3.IncrementProgress));

            m_t1.Name = "Thread 1";
            m_t2.Name = "Thread 2";
            m_t3.Name = "Thread 3";

            //Subscribe to Panel ProgressFinished events in order to determine winner
            pnlThread1.ProgressFinished += new ProgressPanel.ProgresFinishedHandler(pnlThread1_ProgressFinished);
            pnlThread2.ProgressFinished += new ProgressPanel.ProgresFinishedHandler(pnlThread2_ProgressFinished);
            pnlThread3.ProgressFinished += new ProgressPanel.ProgresFinishedHandler(pnlThread3_ProgressFinished);
        }
Пример #2
0
 public ProgressThread(ref ProgressPanel pp, ref ProgressGenerator pg)
 {
     m_Panel = pp;
     m_Generator = pg;
 }
Пример #3
0
 public ProgressThread(ref ProgressPanel pp, ref ProgressGenerator pg)
 {
     m_Panel     = pp;
     m_Generator = pg;
 }