@@ -45,23 +45,20 @@ public PostgreSqlJobQueue(PostgreSqlStorage storage, PostgreSqlStorageOptions op
45
45
_storage = storage ?? throw new ArgumentNullException ( nameof ( storage ) ) ;
46
46
SignalDequeue = new AutoResetEvent ( false ) ;
47
47
}
48
- public PostgreSqlJobQueue ( PostgreSqlStorage storage , PostgreSqlStorageOptions options )
49
- {
50
- _options = options ?? throw new ArgumentNullException ( nameof ( options ) ) ;
51
- _storage = storage ?? throw new ArgumentNullException ( nameof ( storage ) ) ;
52
- }
53
48
49
+ [ NotNull ]
50
+ public IFetchedJob Dequeue ( string [ ] queues , CancellationToken cancellationToken )
51
+ {
52
+ if ( _options . UseNativeDatabaseTransactions )
53
+ return Dequeue_Transaction ( queues , cancellationToken ) ;
54
54
55
- [ NotNull ]
56
- public IFetchedJob Dequeue ( string [ ] queues , CancellationToken cancellationToken )
57
- {
58
- if ( _options . UseNativeDatabaseTransactions )
59
- return Dequeue_Transaction ( queues , cancellationToken ) ;
55
+ return Dequeue_UpdateCount ( queues , cancellationToken ) ;
56
+ }
60
57
61
- /// <summary>
62
- /// Signal the waiting Thread to lookup a new Job
63
- /// </summary>
64
- public void FetchNextJob ( )
58
+ /// <summary>
59
+ /// Signal the waiting Thread to lookup a new Job
60
+ /// </summary>
61
+ public void FetchNextJob ( )
65
62
{
66
63
SignalDequeue . Set ( ) ;
67
64
}
@@ -233,7 +230,13 @@ internal IFetchedJob Dequeue_UpdateCount(string[] queues, CancellationToken canc
233
230
{
234
231
if ( currentQueryIndex == fetchConditions . Length - 1 )
235
232
{
236
- cancellationToken . WaitHandle . WaitOne ( _options . QueuePollInterval ) ;
233
+ WaitHandle . WaitAny ( new [ ]
234
+ {
235
+ cancellationToken . WaitHandle ,
236
+ SignalDequeue
237
+ } ,
238
+ _options . QueuePollInterval ) ;
239
+
237
240
cancellationToken . ThrowIfCancellationRequested ( ) ;
238
241
}
239
242
}
0 commit comments