private async void button1_Click(object sender, RoutedEventArgs e)
        {
            Thread threadLable = new Thread(new ThreadStart(() =>
            {
                while (true)
                {
                    Dispatcher.Invoke(() =>
                    {
                        List <P2PConnection> inNodes = P2PConnectionManager.GetInboundP2PConnections();
                        label.Content = "Inbound: " + inNodes.Count + " Outbound: " + P2PConnectionManager.GetOutboundP2PConnections().Count;

                        if (inNodes.Count > 0)
                        {
                        }
                    });

                    Thread.CurrentThread.Join(1000);
                }
            }));

            threadLable.IsBackground = true;
            threadLable.Start();

            await P2PConnectionManager.ListenForIncomingP2PConnectionsAsync(IPAddress.Any, _networkParameters);
        }
        private async void button5_Click(object sender, RoutedEventArgs e)
        {
            List <PeerAddress> ips = await P2PConnectionManager.GetDNSSeedIPAddressesAsync(P2PNetworkParameters.DNSSeedHosts, _networkParameters);

            Thread threadLable = new Thread(new ThreadStart(() =>
            {
                while (true)
                {
                    Dispatcher.Invoke(() =>
                    {
                        label.Content = "Inbound: " + P2PConnectionManager.GetInboundP2PConnections().Count + " Outbound: " + P2PConnectionManager.GetOutboundP2PConnections().Count;
                    });
                    Thread.CurrentThread.Join(1000);
                }
            }));

            threadLable.IsBackground = true;
            threadLable.Start();

            foreach (PeerAddress ip in ips)
            {
                Thread connectThread = new Thread(new ThreadStart(() =>
                {
                    P2PConnection p2p = new P2PConnection(ip.IPAddress, _networkParameters, new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp));
                    p2p.ConnectToPeer(1);
                }));
                connectThread.IsBackground = true;
                connectThread.Start();
            }
        }
        private void button_Click(object sender, RoutedEventArgs e)
        {
            Thread connectThread = new Thread(new ThreadStart(() =>
            {
                ushort port = 8333;

                if (_networkParameters.IsTestNet)
                {
                    port = 18333;
                }

                p2p          = new P2PConnection(IPAddress.Parse("82.45.214.119"), _networkParameters, new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp), port);
                bool success = p2p.ConnectToPeer(1);

                if (!success)
                {
                    MessageBox.Show("Not connected");
                }
            }));

            connectThread.IsBackground = true;
            connectThread.Start();

            Thread threadLable = new Thread(new ThreadStart(() =>
            {
                while (true)
                {
                    Dispatcher.Invoke(() =>
                    {
                        label.Content = "Inbound: " + P2PConnectionManager.GetInboundP2PConnections().Count + " Outbound: " + P2PConnectionManager.GetOutboundP2PConnections().Count;
                    });
                    Thread.CurrentThread.Join(250);
                }
            }));

            threadLable.IsBackground = true;
            threadLable.Start();
        }