wonderful world
wonderful world

Reputation: 11599

Does the delegate::Invoke and ThreadPool::QueueWorkerItem in C# do the same job?

The synchronous calls in C# can be converted to a asynchronous calls by creating a new delegate, and then the BeginInvoke can be called on that delegate. The same operation can be done by without creating a delegate, but call the ThreadPool::QueueWorkerItem method. As I understand both methods do the same job. The delegate::BeginInvoke is little more coding but easy to understand. Do these operations both use thread pool to do the asynchronous operation internally?

Upvotes: 0

Views: 61

Answers (1)

wonderful world
wonderful world

Reputation: 11599

After testing a sample app, I have found out that delegate::BeginInvoke invokes the call in a different thread. Internally it might be using ThreadPool to create a background worker thread to complete the job because the callback can't modify the controls which is created by the UI thread.

Upvotes: 0

Related Questions