Do I need to call the EndInvoke on a delegate passed to ThreadPool.QueueUserWorkItem?
I am using this suggestion to call the ThreadPoolQueueWorkItem.
ThreadPool.QueueUserWorkItem(
delegate { someDelegate(arg1, arg2); }
);
If i need to call endinvoke, how do I call it? Thanks.
No, you don’t need to call it. In fact, you shouldn’t 🙂
You should only call EndInvoke to end an asynchronous invocation previously started by calling BeginInvoke.
In the code you have provided you are running the delegate synchronously from a ThreadPool thread.
This approach is just fine when you have a “fire and forget” requirement. However, if you need to retrieve output from the invocation it would be better to use BeginInvoke followed by EndInvoke.