Files
DE70/.svn/pristine/a9/a9238a038b2c31d906823520723915267c2a0d32.svn-base
2024-09-02 10:03:23 +07:00

41 lines
1.1 KiB
Plaintext

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace SafeBagDE70.Services
{
internal class WarningSoundManager2
{
private static bool _isWarningActive = false;
private static Thread _warningSoundThread;
public static void StartWarningSound()
{
if (!_isWarningActive)
{
_isWarningActive = true;
_warningSoundThread = new Thread(PlayWarningSound);
_warningSoundThread.IsBackground = true; // Ensure the thread stops when the application exits
_warningSoundThread.Start();
}
}
public static void StopWarningSound()
{
_isWarningActive = false;
}
private static void PlayWarningSound()
{
while (_isWarningActive)
{
Console.Beep(1200, 500); // Frequency: 1200 Hz, Duration: 500 ms
Thread.Sleep(500); // Pause for 500 ms before repeating for 100ms
}
}
}
}