@@ -104,6 +104,24 @@ public async Task TestUnthrottledFloodPublishing()
104
104
string queueName = q . QueueName ;
105
105
106
106
var exceptions = new ConcurrentBag < Exception > ( ) ;
107
+
108
+ async Task WaitPublishTasksAsync ( ICollection < ValueTask > publishTasks )
109
+ {
110
+ foreach ( ValueTask pt in publishTasks )
111
+ {
112
+ try
113
+ {
114
+ await pt ;
115
+ }
116
+ catch ( Exception ex )
117
+ {
118
+ exceptions . Add ( ex ) ;
119
+ }
120
+ }
121
+
122
+ publishTasks . Clear ( ) ;
123
+ }
124
+
107
125
var stopwatch = Stopwatch . StartNew ( ) ;
108
126
int publishCount = 0 ;
109
127
try
@@ -118,18 +136,7 @@ public async Task TestUnthrottledFloodPublishing()
118
136
{
119
137
if ( stopwatch . Elapsed > ElapsedMax )
120
138
{
121
- foreach ( ValueTask pt in publishTasks )
122
- {
123
- try
124
- {
125
- await pt ;
126
- }
127
- catch ( Exception ex )
128
- {
129
- exceptions . Add ( ex ) ;
130
- }
131
- }
132
- publishTasks . Clear ( ) ;
139
+ await WaitPublishTasksAsync ( publishTasks ) ;
133
140
return ;
134
141
}
135
142
@@ -139,33 +146,11 @@ public async Task TestUnthrottledFloodPublishing()
139
146
140
147
if ( i % 128 == 0 )
141
148
{
142
- foreach ( ValueTask pt in publishTasks )
143
- {
144
- try
145
- {
146
- await pt ;
147
- }
148
- catch ( Exception ex )
149
- {
150
- exceptions . Add ( ex ) ;
151
- }
152
- }
153
- publishTasks . Clear ( ) ;
149
+ await WaitPublishTasksAsync ( publishTasks ) ;
154
150
}
155
151
}
156
152
157
- foreach ( ValueTask pt in publishTasks )
158
- {
159
- try
160
- {
161
- await pt ;
162
- }
163
- catch ( Exception ex )
164
- {
165
- exceptions . Add ( ex ) ;
166
- }
167
- }
168
- publishTasks . Clear ( ) ;
153
+ await WaitPublishTasksAsync ( publishTasks ) ;
169
154
} ) ) ;
170
155
}
171
156
@@ -178,8 +163,7 @@ public async Task TestUnthrottledFloodPublishing()
178
163
179
164
Assert . True ( _conn . IsOpen ) ;
180
165
Assert . False ( sawUnexpectedShutdown ) ;
181
- // if (IsVerbose)
182
- if ( true )
166
+ if ( IsVerbose )
183
167
{
184
168
_output . WriteLine ( "[INFO] published {0} messages in {1}, exceptions: {2}" ,
185
169
publishCount , stopwatch . Elapsed , exceptions . Count ) ;
0 commit comments