当前位置: 首页>>代码示例>>C#>>正文


C# Task.ExecuteEntry方法代码示例

本文整理汇总了C#中System.Threading.Tasks.Task.ExecuteEntry方法的典型用法代码示例。如果您正苦于以下问题:C# Task.ExecuteEntry方法的具体用法?C# Task.ExecuteEntry怎么用?C# Task.ExecuteEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Threading.Tasks.Task的用法示例。


在下文中一共展示了Task.ExecuteEntry方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: QueueTask

        protected internal override void QueueTask(Task task)
        {
#if !FEATURE_PAL && !FEATURE_CORECLR    // PAL and CoreClr don't support  eventing
            var etwLog = TplEtwProvider.Log;
            if (etwLog.IsEnabled(EventLevel.Verbose, ((EventKeywords)(-1))))
            {
                Task currentTask = Task.InternalCurrent;
                Task creatingTask = task.m_parent;

                etwLog.TaskScheduled(this.Id, currentTask == null ? 0 : currentTask.Id,
                                                 task.Id, creatingTask == null ? 0 : creatingTask.Id,
                                                 (int)task.Options);
            }
#endif

            if ((task.Options & TaskCreationOptions.LongRunning) != 0)
            {
                NativeThreadPool.QueueLongRunningWork(() => task.ExecuteEntry(false));
            }
            else
            {
                // Normal handling for non-LongRunning tasks.
                bool forceToGlobalQueue = ((task.Options & TaskCreationOptions.PreferFairness) != 0);
                ThreadPool.UnsafeQueueCustomWorkItem(task, forceToGlobalQueue);
            }
        }
开发者ID:noahfalk,项目名称:corert,代码行数:26,代码来源:ThreadPoolTaskScheduler.cs

示例2: TryExecuteTaskInline

        /// <summary>
        /// This internal function will do this:
        ///   (1) If the task had previously been queued, attempt to pop it and return false if that fails.
        ///   (2) Propagate the return value from Task.ExecuteEntry() back to the caller.
        /// 
        /// IMPORTANT NOTE: TryExecuteTaskInline will NOT throw task exceptions itself. Any wait code path using this function needs
        /// to account for exceptions that need to be propagated, and throw themselves accordingly.
        /// </summary>
        protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
        {
            // If the task was previously scheduled, and we can't pop it, then return false.
            if (taskWasPreviouslyQueued && !ThreadPool.TryPopCustomWorkItem(task))
                return false;

            // Propagate the return value of Task.ExecuteEntry()
            bool rval = false;
            try
            {
                rval = task.ExecuteEntry(false); // handles switching Task.Current etc.
            }
            finally
            {
                //   Only call NWIP() if task was previously queued
                if(taskWasPreviouslyQueued) NotifyWorkItemProgress();
            }

            return rval;
        }
开发者ID:kouvel,项目名称:coreclr,代码行数:28,代码来源:ThreadPoolTaskScheduler.cs

示例3: TryExecuteTaskInline

 protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
 {
     if (taskWasPreviouslyQueued && !ThreadPool.TryPopCustomWorkItem(task))
     {
         return false;
     }
     bool flag = false;
     try
     {
         flag = task.ExecuteEntry(false);
     }
     finally
     {
         if (taskWasPreviouslyQueued)
         {
             this.NotifyWorkItemProgress();
         }
     }
     return flag;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:20,代码来源:ThreadPoolTaskScheduler.cs

示例4: QueueTask

        /// <summary>
        /// Schedules a task to the ThreadPool.
        /// </summary>
        /// <param name="task">The task to schedule.</param>
        protected internal override void QueueTask(Task task)
        {
            if (TaskTrace.Enabled)
            {
                Task currentTask = Task.InternalCurrent;
                Task creatingTask = task.m_parent;

                TaskTrace.TaskScheduled(this.Id, currentTask == null ? 0 : currentTask.Id,
                                                 task.Id, creatingTask == null ? 0 : creatingTask.Id,
                                                 (int)task.Options);
            }

            if ((task.Options & TaskCreationOptions.LongRunning) != 0)
            {
                ThreadPool.QueueLongRunningWork(() => task.ExecuteEntry(false));
            }
            else
            {
                // Normal handling for non-LongRunning tasks.
                bool forceToGlobalQueue = ((task.Options & TaskCreationOptions.PreferFairness) != 0);
                ThreadPool.UnsafeQueueCustomWorkItem(task, forceToGlobalQueue);
            }
        }
开发者ID:tijoytom,项目名称:corert,代码行数:27,代码来源:ThreadPoolTaskScheduler.cs

示例5: TryExecuteTask

        protected bool TryExecuteTask(Task task)
        {
            if (task.ExecutingTaskScheduler != this)
            {
                throw new InvalidOperationException(SR.TaskScheduler_ExecuteTask_WrongTaskScheduler);
            }

            return task.ExecuteEntry(true);
        }
开发者ID:noahfalk,项目名称:corert,代码行数:9,代码来源:TaskScheduler.cs

示例6: TryExecuteTask

 protected bool TryExecuteTask(Task task)
 {
     if (task.ExecutingTaskScheduler != this)
     {
         throw new InvalidOperationException(Environment.GetResourceString("TaskScheduler_ExecuteTask_WrongTaskScheduler"));
     }
     return task.ExecuteEntry(true);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:TaskScheduler.cs

示例7: TryExecuteTaskInline

        protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
        {
            // If the task was previously scheduled, and we can't pop it, then return false.
#if !PFX_LEGACY_3_5
            if (taskWasPreviouslyQueued && !ThreadPool.TryPopCustomWorkItem(task))
            {
                return false;
            }
#endif
            // Propagate the return value of Task.ExecuteEntry()
            bool rval = false;
            try
            {
#if PFX_LEGACY_3_5
                // 3.5 needs atomic state transitions
                rval = task.ExecuteEntry(true); // calling the TaskBase override here, because it handles switching Task.Current etc.
#else
                rval = task.ExecuteEntry(false); // calling the TaskBase override here, because it handles switching Task.Current etc.
#endif

            }
            finally
            {
                //   Only call NWIP() if task was previously queued
                if(taskWasPreviouslyQueued) NotifyWorkItemProgress();
            }

            return rval;
        }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:29,代码来源:ThreadPoolTaskScheduler.cs

示例8: TryExecuteTaskInline

 protected internal override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
 {
     if ((task.CreationOptions & TaskCreationOptions.LongRunning) != 0)
     {
         // LongRunning task are going to run on a dedicated Thread.
         return false;
     }
     // Propagate the return value of Task.ExecuteEntry()
     bool result;
     try
     {
         result = task.ExecuteEntry(true); // handles switching Task.Current etc.
     }
     finally
     {
         //   Only call NWIP() if task was previously queued
         if (taskWasPreviouslyQueued) NotifyWorkItemProgress();
     }
     return result;
 }
开发者ID:mesheets,项目名称:Theraot-CF,代码行数:20,代码来源:ThreadPoolTaskScheduler.net35.cs


注:本文中的System.Threading.Tasks.Task.ExecuteEntry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。