private void UserControl_Unloaded(object sender, RoutedEventArgs e) { if (null != ping) { ping.OnReply -= Ping_OnReply; ping.Stop(); ping.Dispose(); } ping = null; if (null != timer) { timer.Tick -= timer_Tick; timer.Stop(); } timer = null; }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { string host = ConfigManager.Instance.Plaza.SCW.Http.HostName; ping = new NLib.Components.PingManager(); ping.OnReply += Ping_OnReply; ping.Add(host); ping.Interval = 1000; ping.Start(); UpdateUI(); timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(1); timer.Tick += timer_Tick; timer.Start(); }