469,934 Members | 1,924 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

C# ...1 beep 1 second silence

I need to write a C# program that asks for a pattern and for each pattern beeps one and goes silence for 1 second.
This is my code:
for (int i=0;i< pattern; i++)
{
Console.Beep();
***************** //I have no idea what to put for 1 sec of silence


}

any suggestions???
Feb 19 '09 #1
3 3960
Plater
7,872 Expert 4TB
Try using Thread.Sleep()
Feb 19 '09 #2
tlhintoq
3,525 Expert 2GB
Be honest... This is a programming class homework assignment, right?
I'm going to guess the next step to the ambulance siren assignment

Posting guidelines about homework

How much looking around the internet have you done on this? How many different methods have you tried, before asking for help? Have you tried a google search for 'time delay' or 'wait loop' or 'time check' or 'time compare' etc.?

By the way a for loop counting the way you have won't get you 1 second of beeping. It will get you beeping for however long it takes that particular PC to count to your supplied number ("pattern"). A 1 GHz computer will beep 3 times longer than a 3 GHz computer, since it will take longer for it to count to the same maximum number.

You might want to look at DateTime objects. This way you can check the DateTime before you go into the loop, keep checking it while in the loop, and then break out of the loop when the current time is greater than the start time plus 1 second.

TIP: If you read the above paragraph like a word problem, it heavily hints at the code you would write to do it.
Feb 19 '09 #3
vekipeki
229 Expert 100+
@tlhintoq
I wouldn't say too much, since there is a sample in MSDN for Console.Beep that does the same thing:

http://msdn.microsoft.com/en-us/library/4fe3hdb1.aspx
Feb 20 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Leo | last post: by
3 posts views Thread by #Hai | last post: by
5 posts views Thread by Ike | last post: by
4 posts views Thread by Birchy | last post: by
2 posts views Thread by Ferhat Akcin via .NET 247 | last post: by
4 posts views Thread by =?Utf-8?B?UmljaA==?= | last post: by
3 posts views Thread by carthia | last post: by
6 posts views Thread by Anz | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.