If you are implementing an ActiveX control, you need to create a thread pool when the object initializes or when it receives the first request. Then, each send request would be dispatched to the thread pool and return back to the caller. For example, if we refer to the diagram below, the ActiveX controls equivalent to PrintAsync() would be:
DoWork(CallbackObject) // queue request to thread pool; work is not actually done in this function!
return (); // returns immediately
DoWork() queues the request to the thread pool and does not do the work. The thread pool thread then does the work and uses the completion object to signal back to the original caller that the request is done.
Dispatcher dispatcher = Dispatcher.CurrentDispatcher;
// do async work here
dispatcher.Invoke(new Action(() =>
More info on the Dispatcher class: http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher(v=vs.100).aspx
The Dispatcher class (System.Windows.Threading Namespace) is available in the following Dot Net versions:
Dot Net 3.0 (Base version 2.0)
- Dot Net 3.5 (Base version 2.0)
- Dot Net 4.0 (Base version 4.0)
- Dot Net 4.5 (Base version 4.0)