Пример #1
0
        private IAsyncResult InternalBeginProcess(IDocument document, AsyncCallback callback, object context, bool isAsynchronous)
        {
            Util.ThrowOnNullArgument(document, "document");
            AsyncResult asyncResult = new AsyncResult(callback, context);

            this.DiagnosticsSession.TraceDebug <IIdentity>("Called begin process - {0} ", document.Identity);
            DocumentContext documentContext = new DocumentContext(document, asyncResult);

            if (isAsynchronous)
            {
                ThreadPool.QueueUserWorkItem(CallbackWrapper.WaitCallback(new WaitCallback(this.ProcessDocument)), documentContext);
            }
            else
            {
                this.ProcessDocument(documentContext);
            }
            return(asyncResult);
        }