के लिए मैं एकाधिक WebRequest
भेजना चाहता हूं। मैंने ऐसा करने के लिए Parallel.For
लूप का उपयोग किया लेकिन लूप एक बार चलता है और प्रतिक्रिया मिलने के दौरान दूसरी बार त्रुटि देता है।समांतर में एकाधिक WebRequest भेजें।
त्रुटि:
The operation has timed out
कोड:
Parallel.For(0, 10, delegate(int i) {
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
new Uri("http://www.mysite.com/service"));
string dataToSend = "Data";
byte[] buffer = System.Text.Encoding.GetEncoding(1252).
GetBytes(dataToSend);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = buffer.Length;
request.Host = "www.mysite.com";
Stream requestStream = request.GetRequestStream();
requestStream.Write(buffer, 0, buffer.Length);
requestStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
});
यह आपको एक त्रुटि संदेश देता है? वास्तव में? और क्या कोई विशेष विशेष प्रश्न है जिसे आप पूछना चाहते हैं? –
और त्रुटि है ...? – Icarus
अपवाद क्या है, यह कहां होता है? क्या आप वाकई सर्वर का समय समाप्त नहीं कर रहे हैं? –