コード例 #1
0
        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);
            }
        }
コード例 #2
0
ファイル: waitableasync.cs プロジェクト: Eisai/pragmasql
 /// <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)
 {
 }
コード例 #3
0
ファイル: waitableasync.cs プロジェクト: Eisai/pragmasql
 /// <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)
 {
 }
コード例 #4
0
ファイル: waitableasync.cs プロジェクト: Eisai/pragmasql
 protected override void Initialize(AsyncDelegate ad, Sonic.Net.ThreadPool tp, Async[] arrDependentOnAsync,
                                    AsyncCodeBlockExecutionCompleteCallback executionCompleteCallback)
 {
     Initialize(ad, tp, arrDependentOnAsync, executionCompleteCallback, true);
 }
コード例 #5
0
 protected virtual void Initialize(AsyncDelegate ad, ThreadPool tp, async[] arrDependentOnAsync,
                                   AsyncCodeBlockExecutionCompleteCallback executionCompleteCallback)
 {
     Initialize(ad, tp, arrDependentOnAsync, executionCompleteCallback, false);
 }
コード例 #6
0
 /// <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);
 }
コード例 #7
0
 /// <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);
 }
コード例 #8
0
 /// <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);
 }
コード例 #9
0
ファイル: waitableasync.cs プロジェクト: minskowl/Core.Libs
 /// <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)
 {
 }
コード例 #10
0
ファイル: waitableasync.cs プロジェクト: minskowl/Core.Libs
 /// <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)
 {
 }
コード例 #11
0
 /// <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);
 }
コード例 #12
0
 /// <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);
 }