Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mcs/class/corlib/System.Threading.Tasks/Task.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ internal void Schedule ()
status = TaskStatus.WaitingToRun;

// If worker is null it means it is a local one, revert to the old behavior
if (childWorkAdder == null || CheckTaskOptions (taskCreationOptions, TaskCreationOptions.PreferFairness)) {
// If TaskScheduler.Current is not being used, the scheduler was explicitly provided, so we must use that
if (scheduler != TaskScheduler.Current || childWorkAdder == null || CheckTaskOptions (taskCreationOptions, TaskCreationOptions.PreferFairness)) {
scheduler.QueueTask (this);
} else {
/* Like the semantic of the ABP paper describe it, we add ourselves to the bottom
Expand Down
10 changes: 9 additions & 1 deletion mcs/class/corlib/System.Threading.Tasks/TaskScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,15 @@ protected internal virtual bool TryDequeue (Task task)

internal protected bool TryExecuteTask (Task task)
{
return TryExecuteTaskInline (task, false);
if (task.IsCompleted)
return false;

if (task.Status == TaskStatus.WaitingToRun) {
task.Execute (null);
return true;
}

return false;
}

protected abstract bool TryExecuteTaskInline (Task task, bool taskWasPreviouslyQueued);
Expand Down
10 changes: 1 addition & 9 deletions mcs/class/corlib/System.Threading.Tasks/TpScheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,7 @@ protected internal override bool TryDequeue (Task task)

protected override bool TryExecuteTaskInline (Task task, bool taskWasPreviouslyQueued)
{
if (task.IsCompleted)
return false;

if (task.Status == TaskStatus.WaitingToRun) {
task.Execute (null);
return true;
}

return false;
return TryExecuteTask(task);
}

public override int MaximumConcurrencyLevel {
Expand Down