合并 System.Threading.Tasks.NET35
智能大石头 authored at 2023-03-16 23:32:48
901.00 B
X
using System.Collections.Generic;
using System.Security;

namespace System.Threading.Tasks;

internal class TpScheduler : TaskScheduler
{
	private static readonly WaitCallback callback = TaskExecuterCallback;

	public override int MaximumConcurrencyLevel => base.MaximumConcurrencyLevel;

	[SecurityCritical]
	protected internal override void QueueTask(Task task)
	{
		ThreadPool.UnsafeQueueUserWorkItem(callback, task);
	}

	private static void TaskExecuterCallback(object obj)
	{
		Task task = (Task)obj;
		task.Execute();
	}

	protected override IEnumerable<Task> GetScheduledTasks()
	{
		throw new NotImplementedException();
	}

	[SecurityCritical]
	protected internal override bool TryDequeue(Task task)
	{
		throw new NotImplementedException();
	}

	[SecurityCritical]
	protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
	{
		return TryExecuteTask(task);
	}
}