private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { DateTime currentTime = DateTime.Now; DateTime userTime = dateTimePicker1.Value; if (currentTime.Hour == userTime.Hour && currentTime.Minute == userTime.Minute && currentTime.Second == userTime.Second) { timer.Stop(); try { updateDataLable UpdateDataLable = null; updateDataLable upd = UpdateDataLable; if (label2.InvokeRequired) { Invoke(upd, lblStatus, "stop"); } SoundPlayer player = new SoundPlayer(); player.SoundLocation = @"C:\Windows\Media\Alarm01.wav"; player.PlayLooping(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void Invoke(updateDataLable upd, object lblStatus, string v) { }