简体   繁体   中英

after using system events my wpf application runs from some save state

I use SystemEvent.timecahnged in my wpf application.After execute the program my application save that state and alway runs from that.I changed many things in my code but it always run from the same state. the code i use for SystemEvent.TimeChanged is :

private void StartListening()
{
    Microsoft.Win32.SystemEvents.TimeChanged += new EventHandler(TimeHandler);
}

private void StopListening()
{
    Microsoft.Win32.SystemEvents.TimeChanged -= new  EventHandler(TimeHandler);
}

private void TimeHandler(object sender, EventArgs e)
{
    DataAccess da = new DataAccess();
    String activity = "Time is Changed";
    String datetime = DateTime.Now.ToString("yyyy-MM-dd HH':'mm':'ss");
    String[] list = datetime.Split(' ');
    String date = list[0].ToString();
    String time = list[1].ToString();
    da.addActivity(activity, date, time);
}

清理构建项目,然后再次运行,希望它能正常工作

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM