Esempio n. 1
0
 private void ButtonCalculate_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         TextBoxOutPut.Clear();
         Result = "";
         I      = 0;
         var pi1    = double.Parse(Pi1TextBox.Text, CultureInfo.InvariantCulture);
         var pi2    = double.Parse(Pi2TextBox.Text, CultureInfo.InvariantCulture);
         var system = new QueuingSystemClass
         {
             Pi1 = pi1,
             Pi2 = pi2
         };
         Task.Run(() =>
         {
             for (var i = 0; i < BambardCount; i++)
             {
                 lock (this)
                 {
                     Result = Result + system.ProcessTick();
                     I      = i;
                 }
                 timer.Start();
             }
             system.CalcStats(out var A, out var P, out var L, BambardCount);
             Dispatcher.Invoke(() =>
             {
                 LabelAbsoluteProbability.Content     = A.ToString(CultureInfo.InvariantCulture);
                 LabelProbabilityOfRegectiong.Content = P.ToString(CultureInfo.InvariantCulture);
                 LabelQueryLength.Content             = L.ToString(CultureInfo.InvariantCulture);
             });
         });
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
Esempio n. 2
0
 private void ButtonCalculate_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var peopleIntensity = double.Parse(Pi1TextBox.Text, CultureInfo.InvariantCulture);
         var carIntensity    = double.Parse(Pi2TextBox.Text, CultureInfo.InvariantCulture);
         var system          = new QueuingSystemClass
         {
             PeopleIntensity = peopleIntensity,
             CarIntensity    = carIntensity
         };
         Task.Run(() =>
         {
             Stopwatch SW = new Stopwatch();
             SW.Start();
             for (var i = 0; i < BombardTime; i++)
             {
                 system.ProcessTick();
             }
             system.CalcStats(out var peopleQueryLength, out var carQueryLength, out var peopleWaitTime,
                              out var carWaitTime, out var chanceToLeave, BombardTime);
             SW.Stop();
             Dispatcher.Invoke(() =>
             {
                 LabelPeopleQueryLength.Content  = peopleQueryLength.ToString(CultureInfo.InvariantCulture);
                 LabelVehicleQueryLength.Content = carQueryLength.ToString(CultureInfo.InvariantCulture);
                 LabelPeopleWait.Content         = peopleWaitTime.ToString(CultureInfo.InvariantCulture);
                 LabelVehicleWait.Content        = carWaitTime.ToString(CultureInfo.InvariantCulture);
                 ProbabilityToLeave.Content      = chanceToLeave.ToString(CultureInfo.InvariantCulture);
                 TextBlock.Text = SW.Elapsed.ToString();
             });
         });
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
     }
 }