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 } } } }