Interface IAsyncQueueBase<TItem>
Interface that represents a queue, that can be proccessed by AsyncQueueProcessor<TItem>.
Namespace: SuperOffice.Threading
Assembly: SoCore.dll
Syntax
public interface IAsyncQueueBase<TItem>
Type Parameters
| Name | Description |
|---|---|
| TItem |
Properties
HasItemsInTheQueue
True if there are items in the queue
Declaration
bool HasItemsInTheQueue { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
ProcessItemsAsync(AsyncQueueProcessItemAsync<TItem>, CancellationToken)
Process items in the queue
Declaration
Task ProcessItemsAsync(AsyncQueueProcessItemAsync<TItem> processor, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| AsyncQueueProcessItemAsync<TItem> | processor | Processor responsible for processing each item in the queue |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
ProcessNextItemAsync(AsyncQueueProcessItemAsync<TItem>, CancellationToken)
Process the next item in the queue. Wait for there to be an item in the queue.to start processing
Declaration
Task ProcessNextItemAsync(AsyncQueueProcessItemAsync<TItem> processor, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| AsyncQueueProcessItemAsync<TItem> | processor | Processor responsible for processing each item in the queue |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
ToArray(bool)
Get a snapshot of all the items in the queue
Declaration
TItem[] ToArray(bool includeItemsBeingProcessed)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | includeItemsBeingProcessed | Include items currently being processed in the snapshot |
Returns
| Type | Description |
|---|---|
| TItem[] |
WaitForItemsInQueueToBeProcessedAsync(CancellationToken)
Wait for all items currently in the queue or currently being processed to be processed.
Declaration
Task WaitForItemsInQueueToBeProcessedAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
Remarks
This method waits for items in the queue, items being process and any overflow tasks returned by the processor.
Exceptions
| Type | Condition |
|---|---|
| AggregateException | Thrown if any of the awaiting tasks throw an exception. |
| OperationCanceledException | Thrown if the operation is canceled. |