private void Window_Loaded(object sender, RoutedEventArgs e) { gdOPCService.Visibility = Visibility.Collapsed; //Connect to Open Plant OPC Service ThreadPool.QueueUserWorkItem(delegate { string LocalPipeName = "VlixOPC"; this.OPCClassic_Browser.ConnectToBackEndViaLocalHostPipe(LocalPipeName); this.OPCUA_Browser.ConnectToBackEndViaLocalHostPipe(LocalPipeName); (wCFClient = new WCFClient <iOPCServiceContract>(LocalPipeName, "", 500) { OnWCFConnected = (Channel, OPConnection) => { WCFChannel = (iOPCServiceContract)Channel; this.Dispatcher.BeginInvoke(new Action(() => { gdOPCService.Visibility = Visibility.Visible; })); }, OnWCFDisconnected = () => { WCFChannel = null; this.Dispatcher.BeginInvoke(new Action(() => gdOPCService.Visibility = Visibility.Hidden)); } }).Start(); if (wCFClient.ConnectionOK) { this.Dispatcher.BeginInvoke(new Action(() => gdOPCService.Visibility = Visibility.Visible)); } else { this.Dispatcher.BeginInvoke(new Action(() => gdOPCService.Visibility = Visibility.Hidden)); } }); ThreadPool.QueueUserWorkItem(delegate { while (true) { if (!PausePeriodicLogRefresh && WCFChannel != null) { try { if (WCFChannel.TryGetLogs(LastConsoleLogRead, out List <Vlix.LogStruct> LogList)) { LogConsole.AddLogs(LogList); LastConsoleLogRead = LogList.Last().TimeStampInUTC; } } catch { } } Thread.Sleep(1000); } }); }