Results 1 to 3 of 3

Thread: [2.0] Infinite loop tcpclient

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Posts
    116

    Resolved [2.0] Infinite loop tcpclient

    Code:
    private void DoRead(IAsyncResult ar)
            {
                int BytesRead;
                try
                {
                    BytesRead = client.GetStream().EndRead(ar);
    
                    if ((BytesRead < 1)) 
                    {
                        Finished = true;
                        return;
                    }
                    strHTML +=  Encoding.ASCII.GetString(readBuffer, 0, (BytesRead - 2));
    
                    BytesRead = 0;
                    client.GetStream().BeginRead(readBuffer, 0, READ_BUFFER_SIZE, new System.AsyncCallback(this.DoRead), null);
                   
                    
                }
                catch (Exception)
                {
                    // Future Handle
                }
            }
    I call it like this:

    Code:
    client.GetStream().BeginRead(readBuffer, 0, READ_BUFFER_SIZE, new AsyncCallback(DoRead), null);
                while (Finished != true)
                {
                    Application.DoEvents();
                }
                Finished = false;
    I fixed it i just needed to get rid of doevents.
    Last edited by cx323; Jul 29th, 2006 at 05:40 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width