示例#1
0
文件: AlertUtil.cs 项目: qqga/Alert
        static void WaitForAlert(IAlertOptions options)
        {
            if (options.DT.HasValue && options.DT.Value - DateTime.Now is TimeSpan tsToDT && tsToDT.TotalSeconds > 0)
            {
                System.Threading.Thread.Sleep(tsToDT);
            }

            if (options.WaitTime.HasValue)
            {
                System.Threading.Thread.Sleep(options.WaitTime.Value);
            }
        }
示例#2
0
文件: AlertUtil.cs 项目: qqga/Alert
        public static void Alert(IAlertOptions options, Action onAlert = null)
        {
            if (string.IsNullOrEmpty(options.AlertMessage))
            {
                Application.Current.Shutdown();
            }

            WaitForAlert(options);

            Console.Beep();
            Console.WriteLine(options.AlertMessage);
            onAlert?.Invoke();
        }