Hi Wonko,
Firstly, there's a Win32 API function "Beep" which generates simple tones
on the speaker. The function is synchronous; it performs an alertable wait
and does not return control to its caller until the sound finishes.
The definition of this function is as follows:
BOOL Beep(
DWORD dwFreq,
DWORD dwDuration
);
It's similar to the Console.Beep(int, int) method overload. So it seems
that the Console.Beep(int, int) method overload is the wrapper method of
the Beep function.
Secondly, we could use the command "net stop beep" to silence the tone.
When the Console.Beep(int, int) method is being executed and we execute the
command "net stop beep" during the beep, the command window outputs the
following text:
The Beep service is stopping...
Only after the Console.Beep finishes the execution, the command window
outputs the following text:
The Beep service was stopped successfully.
As we can see, the beep service cannot be stopped when the tone is being
used. Only after the tone is free, the beep service can be stopped. So this
is a hardware design and this behavior is by design. And IMO, there's no
better and more controllable method or function than the Console.Beep
method since the Control.Beep is already the wrapper of the Beep function.
As for your question, I suggest that you use a series of short beeps by
calling the Console.Beep(int, int). For example:
for (int i = 0 ; i < 10; i++)
{
Console.Beep(80, 500);
}
Thus, the entire beep will last for 5 seconds. But if you silence the tone
during the beep, the beep will be stopped more promptly.
Hope I make myself clear.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.