Callback - ZjzMisaka/PowerThreadPool GitHub Wiki
The callback feature allows to set callbacks for tasks using the parameters of QueueWorkItem or WorkOption. The default callback can be set using PowerPoolOption.DefaultCallback.
The callback returns an ExecuteResult<TResult> object with the following properties:
ID: Represents the ID of the work.
Result: Represents the result of the work.
Status: Indicates whether the work succeeded or failed.
Exception: If the work failed, this property contains the associated exception.
QueueDateTime: Queue datetime.
StartDateTime: Start datetime.
EndDateTime: End datetime.
RetryInfo: Retry information.
Work callback
powerPool.QueueWorkItem(() =>
{
return 100;
}, (res) =>
{
WorkID id = res.ID;
int result = res.Result;
Exception exception = res.Exception;
Status status = res.Status;
// Do something
});Default callback
powerPool.PowerPoolOption = new PowerPoolOption()
{
DefaultCallback = (res) =>
{
// Do something
},
};