private void PingHost() { while (m_AWSCommEndPoint1 != null) { try { m_AWSCommEndPoint1.Ping(m_AWSId); } catch { m_AWSCommEndPoint1 = null; tabItem1.Dispatcher.BeginInvoke(new Action( delegate() { tabItem1.Visibility = Visibility.Collapsed; })); Tab1Grid.Dispatcher.BeginInvoke(new Action( delegate() { Tab1Grid.Visibility = Visibility.Collapsed; })); } Thread.Sleep(1000); } }
public Window1() { InitializeComponent(); m_AWSId = "AWS1_192.168.0.1"; m_ActiveCase = String.Empty; m_AWSCommEndPoint1 = null; m_AWSCommEndPoint2 = null; m_AWSCommEndPoint3 = null; m_AWSCommEndPoint4 = null; }
public Window1() { InitializeComponent(); m_AWSId = "AWS1_192.168.0.1"; m_ActiveCase = String.Empty; m_AWSCommEndPoint1 = null; m_AWSCommEndPoint2 = null; m_AWSCommEndPoint3 = null; m_AWSCommEndPoint4 = null; }
private void ListenForAWSComm() { Boolean createdPanel = false; HostDiscovery awsCommDiscovery = new HostDiscovery(typeof(IWSComm), new TimeSpan(0, 0, 0, 1, 0)); while (!createdPanel) { Collection<EndpointDiscoveryMetadata> AWSCommEndpoints = awsCommDiscovery.GetAvailableConnections(); if (AWSCommEndpoints.Count > 0) { for (Int32 index = 0; index < AWSCommEndpoints.Count; index++) { foreach (XElement xElement in AWSCommEndpoints[index].Extensions) { try { String alias = xElement.Element("HostAlias").Value; break; } catch { continue; } } InstanceContext awsCommCallback = new InstanceContext(new WSCommCallback()); TCPBinding tcpbinding = new TCPBinding(); ServiceEndpoint HostEndPoint = new ServiceEndpoint(ContractDescription.GetContract(typeof(IWSComm)), tcpbinding, AWSCommEndpoints[index].Address); if (index == 0) { // Connect and setup our endpoint m_AWSCommEndPoint1 = new WSCommEndpoint(awsCommCallback, HostEndPoint); tabItem1.Visibility = System.Windows.Visibility.Visible; Tab1Grid.Visibility = System.Windows.Visibility.Visible; Thread Conn1Ping = new Thread(new ThreadStart(PingHost)); Conn1Ping.Start(); } else if (index == 1) { m_AWSCommEndPoint2 = new WSCommEndpoint(awsCommCallback, HostEndPoint); tabItem2.Visibility = System.Windows.Visibility.Visible; Tab2Grid.Visibility = System.Windows.Visibility.Visible; } else if (index == 2) { m_AWSCommEndPoint3 = new WSCommEndpoint(awsCommCallback, HostEndPoint); tabItem3.Visibility = System.Windows.Visibility.Visible; Tab3Grid.Visibility = System.Windows.Visibility.Visible; } else if (index == 3) { m_AWSCommEndPoint4 = new WSCommEndpoint(awsCommCallback, HostEndPoint); tabItem4.Visibility = System.Windows.Visibility.Visible; Tab4Grid.Visibility = System.Windows.Visibility.Visible; } //Show the Tab Page } createdPanel = true; } else { Thread.Sleep(10000); } } }
private void PingHost() { while (m_AWSCommEndPoint1 != null) { try { m_AWSCommEndPoint1.Ping(m_AWSId); } catch { m_AWSCommEndPoint1 = null; tabItem1.Dispatcher.BeginInvoke(new Action( delegate() { tabItem1.Visibility = Visibility.Collapsed; })); Tab1Grid.Dispatcher.BeginInvoke(new Action( delegate() { Tab1Grid.Visibility = Visibility.Collapsed; })); } Thread.Sleep(1000); } }
private void ListenForAWSComm() { Boolean createdPanel = false; HostDiscovery awsCommDiscovery = new HostDiscovery(typeof(IWSComm), new TimeSpan(0, 0, 0, 1, 0)); while (!createdPanel) { Collection <EndpointDiscoveryMetadata> AWSCommEndpoints = awsCommDiscovery.GetAvailableConnections(); if (AWSCommEndpoints.Count > 0) { for (Int32 index = 0; index < AWSCommEndpoints.Count; index++) { foreach (XElement xElement in AWSCommEndpoints[index].Extensions) { try { String alias = xElement.Element("HostAlias").Value; break; } catch { continue; } } InstanceContext awsCommCallback = new InstanceContext(new WSCommCallback()); TCPBinding tcpbinding = new TCPBinding(); ServiceEndpoint HostEndPoint = new ServiceEndpoint(ContractDescription.GetContract(typeof(IWSComm)), tcpbinding, AWSCommEndpoints[index].Address); if (index == 0) { // Connect and setup our endpoint m_AWSCommEndPoint1 = new WSCommEndpoint(awsCommCallback, HostEndPoint); tabItem1.Visibility = System.Windows.Visibility.Visible; Tab1Grid.Visibility = System.Windows.Visibility.Visible; Thread Conn1Ping = new Thread(new ThreadStart(PingHost)); Conn1Ping.Start(); } else if (index == 1) { m_AWSCommEndPoint2 = new WSCommEndpoint(awsCommCallback, HostEndPoint); tabItem2.Visibility = System.Windows.Visibility.Visible; Tab2Grid.Visibility = System.Windows.Visibility.Visible; } else if (index == 2) { m_AWSCommEndPoint3 = new WSCommEndpoint(awsCommCallback, HostEndPoint); tabItem3.Visibility = System.Windows.Visibility.Visible; Tab3Grid.Visibility = System.Windows.Visibility.Visible; } else if (index == 3) { m_AWSCommEndPoint4 = new WSCommEndpoint(awsCommCallback, HostEndPoint); tabItem4.Visibility = System.Windows.Visibility.Visible; Tab4Grid.Visibility = System.Windows.Visibility.Visible; } //Show the Tab Page } createdPanel = true; } else { Thread.Sleep(10000); } } }