Beispiel #1
0
 public void RegisterProtocolDelegate(Protocol protocolType_, ProtocolDelegate delegate_)
 {
     if (_protocolDelegates.ContainsKey(protocolType_))
     {
         ProtocolDelegate temp = _protocolDelegates[protocolType_];
         temp += delegate_;
         _protocolDelegates[protocolType_] = temp;
     }
     else
     {
         _protocolDelegates.Add(protocolType_, delegate_);
     }
 }
Beispiel #2
0
        public InfectiousDepartmentForm()
        {
            //  Инициализация формы
            InitializeComponent();

            //  Устанавливаем начальные значения
            numericUpDownDoctors.Value = _doctors;
            numericUpDownObservationRoomCapacity.Value = _observationRoomCapacity;
            numericUpDownReceiptTime.Value             = _maxReceiptTime;
            numericUpDownRegistrftionTime.Value        = _maxRegistrationTime;
            numericUpDownInfectionTime.Value           = _infectionTime;


            ToProtocolDelegate = new ProtocolDelegate
                                 (
                delegate(String str)
            {
                richTextBoxProtocol.AppendText(str);
            }
                                 );

            PatientEntryRegistration = new PatientDelegate
                                       (
                delegate(Patient patient)
            {
                Semaphore semaphore = patient.Semaphore;
                semaphore.WaitOne();


                Thread thread = new Thread(patient.Run);
                _threads.Add(thread);
                patient.Thread = thread;
                thread.Start();
            }
                                       );

            PatientEntryObservationRoom = new PatientDelegate
                                          (
                delegate(Patient patient)
            {
                patient.InRegistationQueue = false;
                Semaphore semaphore        = patient.Semaphore;
                semaphore.Release();
            }
                                          );


            RemoveCompletedThread = new ThreadDelegate
                                    (
                delegate(Thread thread)
            {
                _threads.Remove(thread);
                if (_threads.Count == 0)
                {
                    _doctorsAvailable.Dispose();

                    foreach (Doctor doctor in _freeDoctors)
                    {
                        String str = String.Format("Врач {0} принял {1} пациентов за время {2}\n", doctor.Number, doctor.Patients,
                                                   doctor.Duration);
                        richTextBoxProtocol.AppendText(str);
                    }


                    _freeDoctors.Clear();
                    _registrationThread    = null;
                    _observationRoomThread = null;


                    SwapEnables();
                    //////
                }
            }
                                    );
        }