1,创建静态倒计时类
public static class CountdownManager
{
private static DispatcherTimer _timer;
private static int _seconds;//使用配置文件统一倒计时秒数
public static string settingValue = ConfigurationManager.AppSettings["ReturnHomepage"];
// 事件,用于通知秒数变化
public static event Action<int> SecondsChanged;static CountdownManager()
{
_timer = new DispatcherTimer();
_timer.Interval = TimeSpan.FromSeconds(1);
_timer.Tick += Timer_Tick;
}public static void Start()
{
_seconds = Convert.ToInt32(settingValue);
_timer.Start();
}public static void Stop()
{
_timer