G
Guest
I have a multithreaded application that is posting XML requests to a remote
web site. As more and more calls are made to
HttpWebRequest.GetRequestStream, the length of time increases for each call
from an initial 2-3 seconds to anywhere from 15-30 seconds. What am I doing
that is causing this method call's duration to increase and how do I make it
run faster? Below is some pseudo-code for the method that is called in a
multi-threaded fashion...
- Jim
private void MultithreadedMethod()
{
string url = ConfigurationManager.AppSettings["providerUrl"];
request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "text/xml";
startCount = Environment.TickCount;
using (Stream s = request.GetRequestStream())
{
elapsedCount = Environment.TickCount - startCount;
//the elapsed time increases with each call
EventLog.WriteEntry("request.GetRequestStream() = " + elapsedCount,
EventLogEntryType.Information);
using (StreamWriter writer = new StreamWriter(s))
{
writer.WriteLine(requestXml);
writer.Flush();
writer.Close();
}
s.Close();
}
request.Timeout = requestTimeoutMilliseconds;
response = request.GetResponse();
//handle the response here
}
web site. As more and more calls are made to
HttpWebRequest.GetRequestStream, the length of time increases for each call
from an initial 2-3 seconds to anywhere from 15-30 seconds. What am I doing
that is causing this method call's duration to increase and how do I make it
run faster? Below is some pseudo-code for the method that is called in a
multi-threaded fashion...
- Jim
private void MultithreadedMethod()
{
string url = ConfigurationManager.AppSettings["providerUrl"];
request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "text/xml";
startCount = Environment.TickCount;
using (Stream s = request.GetRequestStream())
{
elapsedCount = Environment.TickCount - startCount;
//the elapsed time increases with each call
EventLog.WriteEntry("request.GetRequestStream() = " + elapsedCount,
EventLogEntryType.Information);
using (StreamWriter writer = new StreamWriter(s))
{
writer.WriteLine(requestXml);
writer.Flush();
writer.Close();
}
s.Close();
}
request.Timeout = requestTimeoutMilliseconds;
response = request.GetResponse();
//handle the response here
}