Activity Stream
48,167 MEMBERS
6779 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 24
  1.     
    #11
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    Thanks hyperz, Ill give it a go after work.. i know what the problem is, i just font know how to fix

    when im doing a for loop it sends a command to SendAsync witch in turn starts to do a ping, but because of the for lool the 2 time comes around while the first time is stil running :/.

    And yea that 32 byte char i knew it some some thing like that. Thanks
    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


  2.   Sponsored Links

  3.     
    #12
    Respected Developer
    Then use the normal Send in a loop in a new thread.

  4.     
    #13
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    I did try that i think

    PHP Code: 
    int i;
    for(
    i=0;i<=5;i++)
    {
        
    Action Action = new Action(() => pingSender.SendAsync(addressBox.Text,120) )
        new 
    Thread(Action).Start();

    But still frezed and said that i cannot run another ping request until the previous one has finished
    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


  5.     
    #14
    Respected Developer
    Loop inside a new thread, not new threads inside a loop. You only need one thread for this.

    Edit: and still you call SendAsync instead of Send...
    Edit2: you forgot a ";"

  6.     
    #15
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    i get you, and i havent got C# at work, they wont let me upgrade .NET on the network because they havent checked it or w.e,

    Ill try when i get home..

    And just for clarification you mean like

    PHP Code: 
    private void StartButton_Click(......)
    {
        ..........

        
    Action Action = new Action(() => ThreadRunner()); 
        new 
    Thread(Action).Start();
    }

    public 
    void ThreadRunner()
    {
        for(
    i=0;i<=5;i++)
        {
            
    pingSender.SendAsync(addressBox.Text,120);
        }

    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


  7.     
    #16
    Respected Developer
    Code: 
    private void StartButton_Click(......)
    {
        ..........
    
        new Thread(ThreadRunner).Start();
    }
    
    public void ThreadRunner()
    {
        for(i=0;i<=5;i++)
        {
            pingSender.Send(addressBox.Text,120);
        }
    }

  8.     
    #17
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    Thankuuuuu ill give it a go soon as.

    if you was here id kiss you...... maybe not
    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


  9.     
    #18
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    Ok 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(64true);
            
    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 senderEventArgs e)
            {
                
    updatePingValue(PingTimes.Value);
            }

            private 
    void updatePingValue(int Value)
            {
                
    PingAmount PingTimes.Value;
                
    PingAmountLabel.Text "Pings to send: " PingAmount;
            }

            private 
    void startPing_Click(object senderEventArgs 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<= PingAmounti++)
                {
                    
    /*
                     * 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"120bufferoptions);
                }
            }

            public 
    void PingCallback(object senderPingCompletedEventArgs 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 senderEventArgs e)
            {

            }
        }


    ive left some comments in there and filtered it down to the callback i 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


  10.     
    #19
    Respected Developer
    Use an Action + this.Invoke() in your PingCallback. You should also use break points in visual studio for debugging instead of the javascript-ish MessageBox.Show().

  11.     
    #20
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    using the break points the code is not even executing the callback

    If you wwant to see the source you may be able to see the problem straight away, the only reason im making this is a leaning curve. im not just sponging your knowledge bud.

    http://rapidshare.com/files/405979545/SimplePinger.rar
    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


Page 2 of 3 FirstFirst 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Application Error Help
    By makfun in forum Technical Help Desk Support
    Replies: 1
    Last Post: 8th Apr 2012, 06:50 PM
  2. Filesonic but which application
    By erikadurane in forum File Host Discussion
    Replies: 4
    Last Post: 1st Jan 2012, 04:43 AM
  3. Replies: 109
    Last Post: 31st Oct 2011, 06:42 PM
  4. RDA Freezing?
    By EL-Warez in forum Server Management
    Replies: 1
    Last Post: 23rd Sep 2011, 01:40 AM
  5. Application Submission on ddl???????
    By power07 in forum Technical Help Desk Support
    Replies: 0
    Last Post: 1st Jan 2011, 01:02 PM

Tags for this Thread

BE SOCIAL