Пример #1
0
 private void btnStart_Click(object sender, RoutedEventArgs e)
 {
     if (!fanGenerator.IsAlive)
     {
         ResetData();
         fanGenerator = new Thread(FanGenerator);
         fanGenerator.Start();
         CurrStadium.StartServicingVisitors();
     }
 }
Пример #2
0
 private void btnStop_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         fanGenerator.Abort();
         CurrStadium.ResetData();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #3
0
        private void FanGenerator()
        {
            try
            {
                bool isStadiumFull = false;
                while (!isStadiumFull)
                {
                    ushort countPlaces  = 0;
                    ushort countSectors = 0;

                    this.Dispatcher.Invoke(() =>
                    {
                        countSectors = CurrStadium.CountSectors;
                        countPlaces  = (ushort)(CurrStadium.CountPlaces / CurrStadium.CountSectors);
                        CurrStadium.IsStadiumFull();
                        isStadiumFull = CurrStadium.IsStadiumFull();
                    });
                    Fan fan = GenerateFan(countSectors, countPlaces);

                    int generateFunSleep = 0;
                    this.Dispatcher.Invoke(() =>
                    {
                        CurrStadium.EntranceStadiumQueue.Add(fan);
                        generateFunSleep = GenerateFunSleep;
                    });
                    Thread.Sleep(generateFunSleep);
                }
            }
            catch (ThreadAbortException ex)
            {
                MessageBox.Show(ex.Message + " FanGenerator.");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Пример #4
0
 private void myUpDownControl_ValueChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
 {
     CurrStadium.CountPlacesChanged();
 }