Class WorkQueue<TContext>
Maintains a queue of pending work - every WorkItem posting in the queue will be executed by the host of the queue. WorkQueues are useful for coordination of complex data/event flows in multi-threaded/service applications
Inheritance
Implements
Inherited Members
Namespace: NFX.ServiceModel
Assembly: NFX.dll
Syntax
public class WorkQueue<TContext> : IWorkQueue<TContext> where TContext : class
Type Parameters
| Name | Description |
|---|---|
| TContext |
Constructors
WorkQueue(TContext)
Creates an instance of work queue in particular context
Declaration
public WorkQueue(TContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| TContext | context |
WorkQueue(TContext, PostItemFilter<TContext>)
Creates an instance of work queue in particular context with specific woprk item post filter
Declaration
public WorkQueue(TContext context, PostItemFilter<TContext> filter)
Parameters
| Type | Name | Description |
|---|---|---|
| TContext | context | |
| PostItemFilter<TContext> | filter |
Properties
Context
Returns context that work is processed in
Declaration
public TContext Context { get; }
Property Value
| Type | Description |
|---|---|
| TContext |
PendingCount
Returns pending number of work items
Declaration
public int PendingCount { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
ProcessedFailureCount
Returns total number of work items processed with errors by this queue since its creation
Declaration
public long ProcessedFailureCount { get; }
Property Value
| Type | Description |
|---|---|
| System.Int64 |
ProcessedSuccessCount
Returns total number of work items processed without errors by this queue since its creation
Declaration
public long ProcessedSuccessCount { get; }
Property Value
| Type | Description |
|---|---|
| System.Int64 |
ProcessedTotalCount
Returns total number of work items processed with or without errors by this queue since its creation
Declaration
public long ProcessedTotalCount { get; }
Property Value
| Type | Description |
|---|---|
| System.Int64 |
Methods
FetchDueItem()
Takes due item off the queue without executing it and returns it, or returns null when queue is empty.
Declaration
public IWorkItem<TContext> FetchDueItem()
Returns
| Type | Description |
|---|---|
| IWorkItem<TContext> |
PostItem(IWorkItem<TContext>)
Posts work item into the queue in natural queue order (at the end of the queue)
Declaration
public void PostItem(IWorkItem<TContext> work)
Parameters
| Type | Name | Description |
|---|---|---|
| IWorkItem<TContext> | work |
ProcessDueItem()
Processes item in normal queue order (the item that is due to be processed). Returns true when there was an item in the queue. This method does not leak exceptions from work performance unless they are re-thrown by particular work item WorkFailed(error)
Declaration
public bool ProcessDueItem()
Returns
| Type | Description |
|---|---|
| System.Boolean |