예제 #1
0
        private void RefreshList()
        {
            System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
            lvwHosts.BeginUpdate();
            foreach (ListViewItem itmX in lvwHosts.Items)
            {
                SocketPingEntry httpPingEntry = (SocketPingEntry)itmX.Tag;
                try
                {
                    int pingTime = httpPingEntry.Ping();

                    itmX.SubItems[1].Text = pingTime.ToString();
                    if (pingTime > httpPingEntry.PingTimeOutMS)
                    {
                        itmX.ImageIndex       = 2;
                        itmX.BackColor        = Color.Salmon;
                        itmX.SubItems[1].Text = "Time-out (" + pingTime.ToString() + ")";
                    }
                    else
                    {
                        itmX.ImageIndex = 0;
                        itmX.BackColor  = SystemColors.Window;
                    }
                }
                catch (Exception ex)
                {
                    itmX.SubItems[1].Text = ex.Message;
                    itmX.ImageIndex       = 2;
                    itmX.BackColor        = Color.Salmon;
                }
            }
            lvwHosts.EndUpdate();
            System.Windows.Forms.Cursor.Current = Cursors.Default;
            toolStripStatusLabel1.Text          = "Last updated " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        }
예제 #2
0
        private void cmdTestAddress_Click(object sender, EventArgs e)
        {
            SocketPingEntry tmpSocketPingEntry = new SocketPingEntry();

            tmpSocketPingEntry.HostName         = txtAddress.Text;
            tmpSocketPingEntry.PortNumber       = (int)nudPortNumber.Value;
            tmpSocketPingEntry.PingTimeOutMS    = (int)nudTimeOut.Value;
            tmpSocketPingEntry.ReceiveTimeoutMS = (int)nudReceiveTimeout.Value;
            tmpSocketPingEntry.SendTimeoutMS    = (int)nudSendTimeout.Value;
            tmpSocketPingEntry.UseTelnetLogin   = chkUseTelNetLogin.Checked;
            tmpSocketPingEntry.UserName         = txtUserName.Text;
            tmpSocketPingEntry.Password         = txtPassword.Text;
            try
            {
                int pingTime = tmpSocketPingEntry.Ping();
                if (pingTime == int.MaxValue)
                {
                    throw new Exception("An error occured while trying to ping the URL\r\n" + tmpSocketPingEntry.LastError);
                }

                MessageBox.Show(string.Format("Test success!\r\nTime: {0}ms", pingTime), "Test", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }