Skip to content

Commit fb023a5

Browse files
committed
working with the spooler
1 parent 510df43 commit fb023a5

File tree

3 files changed

+166
-151
lines changed

3 files changed

+166
-151
lines changed

ServiceSpooler/Processors/PacketHandler.cs

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -220,53 +220,37 @@ public void DequeuePacket() {
220220
log.Trace("Entering DequeuePacket()");
221221
log.Debug("DequeuePacket() - connected, ready to process");
222222

223-
try {
223+
for (;;) {
224224

225-
for (;;) {
225+
try {
226226

227227
ConnectionEvent.Wait(cancellation.Token);
228228
log.Debug("DequeuePacket() - after ConnectionEvent.Wait()");
229-
dequeueEvent.Wait(cancellation.Token);
230229

230+
dequeueEvent.Wait(cancellation.Token);
231231
log.Debug("DequeuePacket() - processing");
232232

233-
if (cancellation.IsCancellationRequested) {
234-
235-
log.Debug("DequeuePacket() - cancellation requested");
236-
goto fini;
237-
238-
}
239-
240233
Packet packet;
241234

242235
while (queued.TryDequeue(out packet)) {
243236

244-
if (cancellation.IsCancellationRequested) {
245-
246-
log.Debug("DequeuePacket() - cancellation requested");
247-
goto fini;
248-
249-
}
250-
251237
OnDequeuePacket(packet);
252238

253239
}
254240

255-
dequeueEvent.Reset();
241+
} catch (OperationCanceledException) {
256242

257-
}
243+
log.Debug("DequeuePacket() - Ignored an OperationCanceledException");
244+
break;
258245

259-
fini:;
246+
} catch (Exception ex) {
260247

261-
} catch (OperationCanceledException) {
248+
handler.Errors(ex);
249+
break;
262250

263-
// ignore, the waits were canceled.
264-
265-
log.Debug("DequeuePacket() - Ignored but a OperationCanceledException was thrown");
266-
267-
} catch (Exception ex) {
251+
}
268252

269-
handler.Exceptions(ex);
253+
dequeueEvent.Reset();
270254

271255
}
272256

ServiceSpooler/ServiceSpooler.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<ItemGroup>
3535
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
3636
<SpecificVersion>False</SpecificVersion>
37-
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
37+
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
3838
</Reference>
3939
<Reference Include="System" />
4040
<Reference Include="System.Core" />

0 commit comments

Comments
 (0)