Advertisement
Guest User

Untitled

a guest
Oct 20th, 2024
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. class Program
  2. {
  3. private void Beep(int frequency)
  4. {
  5. Console.Beep(frequency, 100);
  6. }
  7.  
  8. private void PlayMelody(string melody, int timeout)
  9. {
  10. for (int i = 0; i < melody.Length; i++)
  11. {
  12. var freq = Enum.Parse<Frequencies>(melody[i].ToString());
  13.  
  14. Beep((int)freq);
  15. Thread.Sleep(1000);
  16. }
  17. }
  18.  
  19. public Task PlayMelodyAsync(string melody, int timeout) => Task.Run(() => PlayMelody(melody, timeout));
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement