private void button_Click(object sender, RoutedEventArgs e) { factory = new FactoryPerson(); queue = new Queue(); GuardedSuspension.TimeForPull = TimeSpan.FromMilliseconds(Convert.ToInt32(Queue.Text)); GuardedSuspension.TimeForPush = TimeSpan.FromMilliseconds(Convert.ToInt32(newClient.Text)); GuardedSuspension.Counter = 0; timer1 = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(50) }; timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(50) }; timerRed = new DispatcherTimer() { Interval = GuardedSuspension.TimeForPull }; timerGreen = new DispatcherTimer() { Interval = GuardedSuspension.TimeForPush }; Iteration = new GuardedSuspension(queue, factory); List.Items.Clear(); timer1.Tick += Timer1_Tick; timer.Tick += Timer_Tick; timerRed.Tick += TimerRed_Tick; timerGreen.Tick += TimerGreen_Tick; timer1.Start(); timer.Start(); timerRed.Start(); timerGreen.Start(); }
public GuardedSuspension(Queue queue, FactoryPerson factory) { _queue = queue; _factory = factory; _resultWaiting = new AutoResetEvent(false); startPull(); startPush(); }