File tree Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -24,24 +24,23 @@ CancellationTokenSource tokenSource = new CancellationTokenSource();
24
24
CancellationToken token = tokenSource .Token ;
25
25
26
26
var _jobQueue = new MsmqJobQueue ();
27
- var deObj = _jobQueue .Dequeue (" my-queue" , token );
28
-
29
- try
27
+ using (var deObj = _jobQueue .Dequeue (" my-queue" , token ))
30
28
{
31
- if ( deObj . Result is Product prod )
29
+ try
32
30
{
33
- Console .WriteLine ($" - processing product <{prod .Id }>" );
31
+ if (deObj .Result is Product prod )
32
+ {
33
+ Console .WriteLine ($" - processing product <{prod .Id }>" );
34
+ }
35
+ deObj .Commit ();
34
36
}
35
- deObj .Commit ();
36
- }
37
- catch (Exception ex )
38
- {
39
- Console .WriteLine ($" Error: {ex .Message }" );
37
+ catch (Exception ex )
38
+ {
39
+ Console .WriteLine ($" Error: {ex .Message }" );
40
40
41
- deObj .Abort ();
41
+ deObj .Abort ();
42
+ }
42
43
}
43
-
44
- deObj .Dispose ();
45
44
```
46
45
47
46
### Feature:
You can’t perform that action at this time.
0 commit comments