Hello,
>>i want to the requests send fast as possible, so they should not be wait for respond even in MILISOCONDS
if you want to send request as fast as possible . You could use the multithreading technology, but creating a thread is also a time-consuming operation. and The HTTP communicate is based on the tcp protocol . The tcp protocol is working at a
transport layer . It will send the request packet one by one base on the net speed. In other words, the speed of sending request is affected by many factors. As for the code , the optimized Code is take multi-threading . Something like below.
//static HttpWebRequest request;
static void Main(string[] args)
{
for (int j = 1; j <= 100; j++)
{
new Thread(PostForm).Start();
}
Console.ReadKey();
}
private static void PostForm()
{
....
Console.WriteLine("ID == " + System.Threading.Thread.CurrentThread.ManagedThreadId);
....
}
Sincerely,
neil hu
这篇关于如何在C#中通过TCP发送Fire& Forget Post Request? (无需等待回复)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!