private TraceClientProxy() { TraceServiceCallback callback = new TraceServiceCallback(); InstanceContext clientContext = new InstanceContext(callback); m_clientProxy = new TraceServiceClient(clientContext); m_clientProxy.Open(); _isConnected = true; m_clientProxy.Verify("123", "456"); DispatcherTimer timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromSeconds(1); timer.Tick += new EventHandler(timer_Tick); timer.Start(); LoadModel(); }
void timer_Tick(object sender, EventArgs e) { if (m_clientProxy.State.HasFlag(CommunicationState.Faulted) || m_clientProxy.State.HasFlag(CommunicationState.Closed)) { GC.Collect(); GC.WaitForPendingFinalizers(); TraceServiceCallback callback = new TraceServiceCallback(); InstanceContext clientContext = new InstanceContext(callback); m_clientProxy = new TraceServiceClient(clientContext); m_clientProxy.Open(); m_clientProxy.Verify("123", "456"); LoadModel(); } else { LoadModel(); } }