1

Closed

PostExecute Callback Sample

description

I couldn't find an valid sample code using the PostExecute Callback feature.

Can you provide a valid sample, please?
Closed Aug 22, 2012 at 6:27 AM by

comments

ddragut wrote Dec 4, 2011 at 8:13 PM

You can see some examples in the tests:
http://smartthreadpool.codeplex.com/SourceControl/changeset/view/32787#203012

I've just started using SmartThreadPool, using the post execute to calculate a progress bar indicator, not sure whether the best method, but it works for me...

foreach (MessageRun messageRun in this.MessageRuns)
{
smartThreadPool.QueueWorkItem(new WorkItemCallback(SmartThreadPool_WorkItemCallback),
                            messageRun,
                            new PostExecuteWorkItemCallback(SmartThreadPool_PostExecuteWorkItemCallback));
}
smartThreadPool.Start();

[...]

private void SmartThreadPool_PostExecuteWorkItemCallback(IWorkItemResult workItemResult)
{
// Increment number of messages processed...
messagesProcessed = messagesProcessed + 1;
}