public frmProducerConsumer()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            Random randTime = new Random();

            m_SharedRes       = new HoldResourceSynchronized(txtBxOutput);
            txtBxOutput.Text += m_SharedRes.CreateStateOutput();

            Producer producer = new Producer(m_SharedRes, randTime, txtBxOutput);
            Consumer consumer = new Consumer(m_SharedRes, randTime, txtBxOutput);

            m_ProducerThread      = new Thread(new ThreadStart(producer.Produce));
            m_ProducerThread.Name = "Producer";

            m_ConsumerThread      = new Thread(new ThreadStart(consumer.Consume));
            m_ConsumerThread.Name = "Consumer";

            m_GeneralState = ThreadState.Unstarted;
        }
Exemple #2
0
 public Consumer(HoldResourceSynchronized shared, Random rand, TextBox ctrlOutput)
 {
     //
     // TODO: Add constructor logic here
     //
     m_SharedResource = shared;
     m_randSleepTime  = rand;
     m_txtBxOutput    = ctrlOutput;
 }