Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- private void Beep(int frequency)
- {
- Console.Beep(frequency, 100);
- }
- private void PlayMelody(string melody, int timeout)
- {
- for (int i = 0; i < melody.Length; i++)
- {
- var freq = Enum.Parse<Frequencies>(melody[i].ToString());
- Beep((int)freq);
- Thread.Sleep(1000);
- }
- }
- public Task PlayMelodyAsync(string melody, int timeout) => Task.Run(() => PlayMelody(melody, timeout));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement