Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private async Task BeepAsync(int frequency)
- {
- await Task.Run(() => { Console.Beep(frequency, 100); });
- }
- private async Task PlayMelody(string melody, int timeout)
- {
- for (int i = 0; i < melody.Length; i++)
- {
- switch (melody[i])
- {
- case 'A':
- await BeepAsync((int)Frequencies.A);
- await Task.Delay(1000);
- break;
- case 'B':
- await BeepAsync((int)Frequencies.B);
- await Task.Delay(1000);
- break;
- case 'C':
- await BeepAsync((int)Frequencies.C);
- await Task.Delay(1000);
- break;
- case 'D':
- await BeepAsync((int)Frequencies.D);
- await Task.Delay(1000);
- break;
- case 'E':
- await BeepAsync((int)Frequencies.E);
- await Task.Delay(1000);
- break;
- case 'F':
- await BeepAsync((int)Frequencies.F);
- await Task.Delay(1000);
- break;
- case 'G':
- await BeepAsync((int)Frequencies.G);
- await Task.Delay(1000);
- break;
- default:
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement