- static void Main()
- {
- var url = new Uri("http://localhost:8012/Handler.ashx");
- var num = 50;
- for (int i = 0; i < num; i++)
- {
- var request = WebRequest.Create(url);
- request.GetResponseAsync().ContinueWith(t =>
- {
- var stream = t.Result.GetResponseStream();
- using (TextReader tr = new StreamReader(stream))
- {
- Console.WriteLine(tr.ReadToEnd());
- }
- });
- }
- Console.ReadLine();
- }
这里,我们同时发起了50个请求,然后观察响应的情况。
【注意】后面的结果会因为操作系统、IIS版本、管道模式、.NET版本、配置项 的不同而不同,以下结果为在Windows Server 2008 R2 + IIS7.5 + .NET 4.5 beta(.NET 4 runtime) + 默认配置 中测试的结果,在没有特别说明的情况下,均为重启IIS后第一次运行的情况。
这个程序在我的电脑运行结果是这样的:
- TId:6 App:35898671 Begin:55:30,3176 End:55:40,3182 TPool:2
- TId:5 App:22288629 Begin:55:30,3176 End:55:40,3212 TPool:2
- TId:7 App:12549444 Begin:55:31,0426 End:55:41,0432 TPool:3
- TId:8 App:22008501 Begin:55:31,5747 End:55:41,5752 TPool:4
- TId:9 App:37121646 Begin:55:32,1067 End:55:42,1073 TPool:5
- TId:10 App:33156464 Begin:55:32,6387 End:55:42,6393 TPool:6
- TId:11 App:7995840 Begin:55:33,1707 End:55:43,1713 TPool:7
- TId:12 App:36610825 Begin:55:33,7028 End:55:43,7033 TPool:8
- TId:13 App:20554616 Begin:55:34,2048 End:55:44,2054 TPool:9
- TId:14 App:15510466 Begin:55:35,2069 End:55:45,2074 TPool:10
- TId:15 App:23324256 Begin:55:36,2049 End:55:46,2055 TPool:11
- TId:16 App:34250480 Begin:55:37,2050 End:55:47,2055 TPool:12
- TId:17 App:58408916 Begin:55:38,2050 End:55:48,2056 TPool:13
- TId:18 App:2348279 Begin:55:39,2051 End:55:49,2057 TPool:14
- TId:19 App:61669314 Begin:55:40,2051 End:55:50,2057 TPool:15
- TId:6 App:35898671 Begin:55:40,3212 End:55:50,3217 TPool:15
- TId:5 App:22288629 Begin:55:40,3232 End:55:50,3237 TPool:15
- TId:7 App:12549444 Begin:55:41,0432 End:55:51,0438 TPool:15
- TId:8 App:22008501 Begin:55:41,5752 End:55:51,5758 TPool:15
- TId:9 App:37121646 Begin:55:42,1073 End:55:52,1078 TPool:15
- TId:10 App:33156464 Begin:55:42,6393 End:55:52,6399 TPool:15
- TId:11 App:7995840 Begin:55:43,1713 End:55:53,1719 TPool:15
- TId:12 App:36610825 Begin:55:43,7043 End:55:53,7049 TPool:15
- TId:13 App:20554616 Begin:55:44,2054 End:55:54,2059 TPool:15
- TId:20 App:36865354 Begin:55:45,2074 End:55:55,2080 TPool:16
- TId:14 App:15510466 Begin:55:45,2084 End:55:55,2090 TPool:16
- TId:21 App:3196068 Begin:55:46,2055 End:55:56,2061 TPool:17
- TId:15 App:23324256 Begin:55:46,2065 End:55:56,2071 TPool:17
- TId:22 App:4186222 Begin:55:47,2055 End:55:57,2061 TPool:18
- TId:16 App:34250480 Begin:55:47,2065 End:55:57,2071 TPool:18
- TId:23 App:764807 Begin:55:48,2046 End:55:58,2052 TPool:19
- TId:17 App:58408916 Begin:55:48,2056 End:55:58,2062 TPool:19
- TId:24 App:10479095 Begin:55:49,2047 End:55:59,2052 TPool:20
- TId:18 App:2348279 Begin:55:49,2057 End:55:59,2062 TPool:20
- TId:25 App:4684807 Begin:55:50,2047 End:56:00,2053 TPool:21
- TId:19 App:61669314 Begin:55:50,2057 End:56:00,2063 TPool:21
- TId:6 App:35898671 Begin:55:50,3227 End:56:00,3233 TPool:21
- TId:5 App:22288629 Begin:55:50,3237 End:56:00,3243 TPool:21
- TId:7 App:12549444 Begin:55:51,0438 End:56:01,0443 TPool:21
- TId:8 App:22008501 Begin:55:51,5758 End:56:01,5764 TPool:21
- TId:9 App:37121646 Begin:55:52,1078 End:56:02,1084 TPool:21
- TId:10 App:33156464 Begin:55:52,6399 End:56:02,6404 TPool:21
- TId:11 App:7995840 Begin:55:53,1719 End:56:03,1725 TPool:21
- TId:26 App:41662089 Begin:55:53,7049 End:56:03,7055 TPool:22
- TId:12 App:36610825 Begin:55:53,7059 End:56:03,7065 TPool:22
- TId:13 App:20554616 Begin:55:54,2069 End:56:04,2075 TPool:22
- TId:27 App:46338128 Begin:55:55,2070 End:56:05,2076 TPool:23
- TId:14 App:15510466 Begin:55:55,2090 End:56:05,2096 TPool:23
- TId:20 App:36865354 Begin:55:55,2090 End:56:05,2096 TPool:23
- TId:28 App:28975576 Begin:55:56,2051 End:56:06,2056 TPool:24
从