protected void Initialize(AsyncDelegate ad, ThreadPool tp, async[] arrDependentOnAsync, AsyncCodeBlockExecutionCompleteCallback executionCompleteCallback, bool waitable) { if (ad == null) { return; } _waitable = waitable; _ad = ad; threadPool = tp; _targetObject = ad.Target; _targetType = ad.Method.DeclaringType; if (_waitable) { _task = new WaitableAsyncDelegateTask(ad) { TaskCompleted = MarkCompleted }; } else { _task = new AsyncDelegateTask(ad) { TaskCompleted = MarkCompleted }; } _executionCompleteCallback = executionCompleteCallback; bool dispatchForExecution = true; if (arrDependentOnAsync != null) { lock (_syncObject) { foreach (async asyncObj in arrDependentOnAsync) { if (asyncObj.AddToDependencyCodeBlockList(this)) { _dependentCount++; } } if (_dependentCount == 0) { dispatchForExecution = true; } else { dispatchForExecution = false; } } } // Store the current SynchronizationContext // _synchronizationContext = SynchronizationContext.Current; if (dispatchForExecution) { Execute(ad, _task, tp); } }
/// <summary> /// Creates an instance of waitableasync class, that executes /// the wrapped code block on the developer supplied /// Managed IOCP based ThreadPool /// </summary> /// <param name="ad"> /// Anonymous delegate wrapping the code block to execute /// </param> /// <param name="tp">Managed IOCP based ThreadPool object</param> /// <param name="executionCompleteCallback"> /// Delegate handler that will be called when the execution of the /// code block wrapped by this instance is completed. Dependent /// async objects will be scheduled for execution after the /// completion callback has executed /// </param> public waitableasync(AsyncDelegate ad, Sonic.Net.ThreadPool tp, AsyncCodeBlockExecutionCompleteCallback executionCompleteCallback) : base(ad, tp, executionCompleteCallback) { }
/// <summary> /// Creates an instance of waitableasync class, that executes /// the wrapped code block on the default AppDomain wide /// Managed IOCP based ThreadPool /// </summary> /// <param name="ad"> /// Anonymous delegate wrapping the code block to execute /// </param> /// <param name="executionCompleteCallback"> /// Delegate handler that will be called when the execution of the /// code block wrapped by this instance is completed. Dependent /// async objects will be scheduled for execution after the /// completion callback has executed /// </param> public waitableasync(AsyncDelegate ad, AsyncCodeBlockExecutionCompleteCallback executionCompleteCallback) : base(ad, executionCompleteCallback) { }
protected override void Initialize(AsyncDelegate ad, Sonic.Net.ThreadPool tp, Async[] arrDependentOnAsync, AsyncCodeBlockExecutionCompleteCallback executionCompleteCallback) { Initialize(ad, tp, arrDependentOnAsync, executionCompleteCallback, true); }
protected virtual void Initialize(AsyncDelegate ad, ThreadPool tp, async[] arrDependentOnAsync, AsyncCodeBlockExecutionCompleteCallback executionCompleteCallback) { Initialize(ad, tp, arrDependentOnAsync, executionCompleteCallback, false); }
/// <summary> /// Creates an instance of async class, that executes /// the wrapped code block on the default AppDomain wide /// Managed IOCP based ThreadPool /// </summary> /// <param name="ad"> /// Anonymous delegate wrapping the code block to execute /// </param> /// <param name="dependentOnAsync"> /// async object on which the current instance of async /// depends on. The code wrapped by the current instance /// of async object will be executed after the code wrapped /// by dependentOnAsync object has completed execution /// </param> /// <param name="executionCompleteCallback"> /// Delegate handler that will be called when the execution of the /// code block wrapped by this instance is completed. Dependent /// async objects will be scheduled for execution after the /// completion callback has executed /// </param> public async(AsyncDelegate ad, async dependentOnAsync, AsyncCodeBlockExecutionCompleteCallback executionCompleteCallback) { Initialize(ad, null, new[] { dependentOnAsync }, executionCompleteCallback); }
/// <summary> /// Creates an instance of async class, that executes /// the wrapped code block on the developer supplied /// Managed IOCP based ThreadPool /// </summary> /// <param name="ad">Anonymous delegate wrapping the code block to execute</param> /// <param name="tp">Managed IOCP based ThreadPool object</param> /// <param name="arrDependentOnAsync">The arr dependent on async.</param> /// <param name="executionCompleteCallback">Delegate handler that will be called when the execution of the /// code block wrapped by this instance is completed. Dependent /// async objects will be scheduled for execution after the /// completion callback has executed</param> public async(AsyncDelegate ad, ThreadPool tp, async[] arrDependentOnAsync, AsyncCodeBlockExecutionCompleteCallback executionCompleteCallback) { Initialize(ad, tp, arrDependentOnAsync, executionCompleteCallback); }
/// <summary> /// Creates an instance of async class, that executes /// the wrapped code block on the developer supplied /// Managed IOCP based ThreadPool /// </summary> /// <param name="ad"> /// Anonymous delegate wrapping the code block to execute /// </param> /// <param name="tp">Managed IOCP based ThreadPool object</param> /// <param name="executionCompleteCallback"> /// Delegate handler that will be called when the execution of the /// code block wrapped by this instance is completed. Dependent /// async objects will be scheduled for execution after the /// completion callback has executed /// </param> public async(AsyncDelegate ad, ThreadPool tp, AsyncCodeBlockExecutionCompleteCallback executionCompleteCallback) { Initialize(ad, tp, null, executionCompleteCallback); }
/// <summary> /// Creates an instance of waitableasync class, that executes /// the wrapped code block on the default AppDomain wide or /// developer supplied Managed IOCP based ThreadPool /// </summary> /// <param name="ad"> /// Anonymous delegate wrapping the code block to execute /// </param> /// <param name="tp">Managed IOCP based ThreadPool object</param> /// <param name="dependentOnAsync"> /// async object array on which the current instance of waitableasync /// depends on. The code wrapped by the current instance /// of waitableasync object will be executed after the code wrapped /// by dependentOnAsync object array has completed execution /// </param> /// <param name="executionCompleteCallback"> /// Delegate handler that will be called when the execution of the /// code block wrapped by this instance is completed. Dependent /// async objects will be scheduled for execution after the /// completion callback has executed /// </param> public waitableasync(AsyncDelegate ad, ThreadPool tp, async[] arrDependentOnAsync, AsyncCodeBlockExecutionCompleteCallback executionCompleteCallback) : base(ad, tp, arrDependentOnAsync, executionCompleteCallback) { }
/// <summary> /// Creates an instance of waitableasync class, that executes /// the wrapped code block on the default AppDomain wide /// Managed IOCP based ThreadPool /// </summary> /// </summary> /// <param name="ad"> /// Anonymous delegate wrapping the code block to execute /// </param> /// <param name="dependentOnAsync"> /// async object on which the current instance of waitableasync /// depends on. The code wrapped by the current instance /// of async object will be executed after the code wrapped /// by dependentOnAsync object has completed execution /// </param> /// <param name="executionCompleteCallback"> /// Delegate handler that will be called when the execution of the /// code block wrapped by this instance is completed. Dependent /// async objects will be scheduled for execution after the /// completion callback has executed /// </param> public waitableasync(AsyncDelegate ad, async dependentOnAsync, AsyncCodeBlockExecutionCompleteCallback executionCompleteCallback) : base(ad, dependentOnAsync, executionCompleteCallback) { }
/// <summary> /// Creates an instance of async class, that executes /// the wrapped code block on the default AppDomain wide /// Managed IOCP based ThreadPool /// </summary> /// <param name="ad"> /// Anonymous delegate wrapping the code block to execute /// </param> /// <param name="executionCompleteCallback"> /// Delegate handler that will be called when the execution of the /// code block wrapped by this instance is completed. Dependent /// async objects will be scheduled for execution after the /// completion callback has executed /// </param> public Async(AsyncDelegate ad, AsyncCodeBlockExecutionCompleteCallback executionCompleteCallback) { Initialize(ad, null, null, executionCompleteCallback); }
/// <summary> /// Creates an instance of async class, that executes /// the wrapped code block on the developer supplied /// Managed IOCP based ThreadPool /// </summary> /// <param name="ad"> /// Anonymous delegate wrapping the code block to execute /// </param> /// <param name="tp">Managed IOCP based ThreadPool object</param> /// <param name="dependentOnAsync"> /// async object on which the current instance of async /// depends on. The code wrapped by the current instance /// of async object will be executed after the code wrapped /// by dependentOnAsync object has completed execution /// </param> /// <param name="executionCompleteCallback"> /// Delegate handler that will be called when the execution of the /// code block wrapped by this instance is completed. Dependent /// async objects will be scheduled for execution after the /// completion callback has executed /// </param> public Async(AsyncDelegate ad, Sonic.Net.ThreadPool tp, Async dependentOnAsync, AsyncCodeBlockExecutionCompleteCallback executionCompleteCallback) { Initialize(ad, tp, new Async[] { dependentOnAsync }, executionCompleteCallback); }