How to fix the "Operation was disabled" error

I have a problem that the error "Operation completed" is displayed when loading data.

What can I do to resolve this error? I am using Win forms (C #), here is my code, please check it and give suggestions. Where can I change the code, please help me ...

  public void ProcessData()
        {


            try
            {
            string MessageTitle = "";
            int pages = Convert.ToInt32(txtPages.Text);

            for (int k = Count; k <= pages; k++)
            {

                string url = "http://www.yellowpages.com/" +StateName.ToLower()+ "/" + CategoryName + "?g=" + StateName + "&page=" + k + "&q=" + CategoryName + "";//txtYP.Text + k;
                System.Net.HttpWebRequest httpRequest;
                System.Net.HttpWebResponse httpResponse;
                System.IO.StreamReader SReader;
                string html;
                httpRequest = (System.Net.HttpWebRequest)(System.Net.HttpWebRequest.Create(url));
                httpRequest.Method = "GET";
                httpResponse = (System.Net.HttpWebResponse)(httpRequest.GetResponse());
                SReader = new StreamReader(httpResponse.GetResponseStream());
                html = SReader.ReadToEnd();
                string strDummy = html;
                httpResponse.Close();
+3
source share
2 answers

How much time has passed before the request timed out? Can you go to the url from a web browser?

Sets the property HttpWebRequest.ReadWriteTimeoutin HttpWebRequest to a much higher value than what is currently. The default value is 5 minutes. Not sure why it will take more than 5 minutes.

getresponse (BeginGetResponse/EndGetResponse).

<system.diagnostics>
  <trace autoflush="true" />
  <sources>
    <source name="System.Net">
      <listeners>
        <add name="System.Net"/>
      </listeners>
    </source>
    <source name="System.Net.HttpListener">
      <listeners>
        <add name="System.Net"/>
      </listeners>
    </source>
    <source name="System.Net.Sockets">
      <listeners>
        <add name="System.Net"/>
      </listeners>
    </source>
    <source name="System.Net.Cache">
      <listeners>
        <add name="System.Net"/>
      </listeners>
    </source>
  </sources>
  <sharedListeners>
    <add
      name="System.Net"
      type="System.Diagnostics.TextWriterTraceListener"
      initializeData="trace.log"
      traceOutputOptions = "ProcessId, DateTime"
            />
  </sharedListeners>
  <switches>
    <add name="System.Net"
         value="Verbose" />
    <add name="System.Net.Sockets"
         value="Verbose" />
    <add name="System.Net.Cache"
         value="Verbose" />
    <add name="System.Net.HttpListener"
         value="Verbose" />
  </switches>
</system.diagnostics>  

configuration app.config . , . trace.log, bin .

+1

:

httpRequest.Timeout= 3600000;

.

0