I have a multithreaded application that is posting XML requests to a remote
web site. As more and more calls are made to
HttpWebRequest. GetRequestStrea m, 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 MultithreadedMe thod()
{
string url = ConfigurationMa nager.AppSettin gs["providerUr l"];
request = (HttpWebRequest )WebRequest.Cre ate(url);
request.Method = "POST";
request.Content Type = "text/xml";
startCount = Environment.Tic kCount;
using (Stream s = request.GetRequ estStream())
{
elapsedCount = Environment.Tic kCount - startCount;
//the elapsed time increases with each call
EventLog.WriteE ntry("request.G etRequestStream () = " + elapsedCount,
EventLogEntryTy pe.Information) ;
using (StreamWriter writer = new StreamWriter(s) )
{
writer.WriteLin e(requestXml);
writer.Flush();
writer.Close();
}
s.Close();
}
request.Timeout = requestTimeoutM illiseconds;
response = request.GetResp onse();
//handle the response here
}
web site. As more and more calls are made to
HttpWebRequest. GetRequestStrea m, 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 MultithreadedMe thod()
{
string url = ConfigurationMa nager.AppSettin gs["providerUr l"];
request = (HttpWebRequest )WebRequest.Cre ate(url);
request.Method = "POST";
request.Content Type = "text/xml";
startCount = Environment.Tic kCount;
using (Stream s = request.GetRequ estStream())
{
elapsedCount = Environment.Tic kCount - startCount;
//the elapsed time increases with each call
EventLog.WriteE ntry("request.G etRequestStream () = " + elapsedCount,
EventLogEntryTy pe.Information) ;
using (StreamWriter writer = new StreamWriter(s) )
{
writer.WriteLin e(requestXml);
writer.Flush();
writer.Close();
}
s.Close();
}
request.Timeout = requestTimeoutM illiseconds;
response = request.GetResp onse();
//handle the response here
}
Comment