Results 1 to 10 of 24
Threaded View
-
9th Jul 2010, 04:52 PM #18OPMemberWebsite's:
litewarez.net litewarez.com triniwarez.comOk does some testing and still not working, it seems to be the callback
PHP Code:using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.NetworkInformation;
using System.Threading;
namespace SimplePinger
{
public partial class Form1 : Form
{
#region Variables
int PingAmount = 5;
Ping pingSender = new Ping();
PingOptions options = new PingOptions(64, true);
byte[] buffer = new byte[32];
#endregion
public Form1()
{
InitializeComponent();
updatePingValue(5); //Set defualt to 5
/*Ping Options*/
pingSender.PingCompleted += new PingCompletedEventHandler(PingCallback);
}
private void PingTimes_Scroll(object sender, EventArgs e)
{
updatePingValue(PingTimes.Value);
}
private void updatePingValue(int Value)
{
PingAmount = PingTimes.Value;
PingAmountLabel.Text = "Pings to send: " + PingAmount;
}
private void startPing_Click(object sender, EventArgs e)
{
outputBox.Clear(); /*Fine Here*/
/*
* Start the thread to run the InitiateThreadPinger()
*/
new Thread(InitiateThreadPinger).Start();
}
public void InitiateThreadPinger()
{
/*
* Loop 1-10 and run a ping on the host
*/
options.DontFragment = true;
for (int i = 0; i <= PingAmount; i++)
{
/*
* Send the pingSender the Send command with options, Callback attached in Main()
* The code in here Executes the correct amount of times as i get the Test below
* The problem seems to be that the ping does not execute the callback, Cross Thread Maybe ? ( NO Error Triggered )
*/
//MessageBox.Show("Test");
pingSender.Send("127.0.0.1", 120, buffer, options);
}
}
public void PingCallback(object sender, PingCompletedEventArgs e)
{
if (e.Cancelled)
{
EnableFormElements();
}
if (e.Error != null)
{
MessageBox.Show("Ping Failed:" + e.Error.ToString());
return;
}
PingReply reply = e.Reply;
AddCallbackToForm(reply);
}
public void AddCallbackToForm(PingReply Reply)
{
if (Reply == null)
{
return;
}
if (Reply.Status == IPStatus.Success)
{
outputBox.Text += "Success: " + Reply.Address + " - " + Reply.RoundtripTime + "ms";
}
else
{
outputBox.Text += "Failed...";
}
}
public void EnableFormElements()
{
startPing.Enabled = true;
PingTimes.Enabled = true;
}
public void DisableFormElements()
{
startPing.Enabled = false;
PingTimes.Enabled = false;
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
ive left some comments in there and filtered it down to the callbacki get no errors so its hard for me to track
Join Litewarez.net today and become apart of the community.
Unique | Clean | Advanced (All with you in mind)
Downloads | Webmasters
Notifications,Forum,Chat,Community all at Litewarez Webmasters
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Application Error Help
By makfun in forum Technical Help Desk SupportReplies: 1Last Post: 8th Apr 2012, 06:50 PM -
Filesonic but which application
By erikadurane in forum File Host DiscussionReplies: 4Last Post: 1st Jan 2012, 04:43 AM -
[Hire Me] Freelance Programmer [Rapid Application Development (Windows Application)]
By ?RaJ? in forum Completed TransactionsReplies: 109Last Post: 31st Oct 2011, 06:42 PM -
RDA Freezing?
By EL-Warez in forum Server ManagementReplies: 1Last Post: 23rd Sep 2011, 01:40 AM -
Application Submission on ddl???????
By power07 in forum Technical Help Desk SupportReplies: 0Last Post: 1st Jan 2011, 01:02 PM
themaLeecher - leech and manage...
Version 5.07 released. Open older version (or...