private void SetAction_Click(object sender, RoutedEventArgs e) { string description = ""; try { switch (radioShutdown.IsChecked) { case true: description = "shutdown"; break; case false: description = "restart"; break; } shutDownEvent = new ShutDownEvent(hoursset.SelectedItem.ToString() + ":" + minset.SelectedItem.ToString(), description); eventLabel.Content = description; DeleteActionButton.Visibility = Visibility.Visible; ErrorLabel.Content = ""; timeEventLabel.Content = shutDownEvent.P_Time; notifyForEvent = true; } catch { ErrorLabel.Content = "THE TIME IS NOT SETTING CORRECT!"; } }
private void deleteEvent() { cleanLabels(); shutDownEvent = null; GC.Collect(); GC.WaitForPendingFinalizers(); }
public Speaker(WaveFormat wf) { this.wf = wf; this.Buffer = new BufferedWaveProvider(wf); this.TempBuffer = new byte[150]; this.sd = new ShutDownEvent(); this.sd.ShutDown = false; this.Playback = new Thread(() => Play(this.Buffer, this.sd)); this.Playback.Start(); }
private static void Play(BufferedWaveProvider bf, ShutDownEvent sd) { WaveOut wo = new WaveOut(); // wo.DesiredLatency = 10; wo.NumberOfBuffers = 50; wo.Init(bf); wo.Play(); while (wo.PlaybackState == PlaybackState.Playing && !sd.ShutDown) { Thread.Sleep(500); } wo.Dispose(); }