Created
May 26, 2014 10:27
-
-
Save renestein/edc591dfa69b501d2c48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
namespace RStein.Async.Schedulers | |
{ | |
public class CurrentThreadScheduler : TaskSchedulerBase | |
{ | |
private const int MAXIMUM_CONCURRENCY_LEVEL = 1; | |
public override int MaximumConcurrencyLevel | |
{ | |
get | |
{ | |
checkIfDisposed(); | |
return MAXIMUM_CONCURRENCY_LEVEL; | |
} | |
} | |
public override void QueueTask(Task task) | |
{ | |
checkIfDisposed(); | |
ProxyScheduler.DoTryExecuteTask(task); | |
} | |
public override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued) | |
{ | |
checkIfDisposed(); | |
ProxyScheduler.DoTryExecuteTask(task); | |
return true; | |
} | |
public override IEnumerable<Task> GetScheduledTasks() | |
{ | |
checkIfDisposed(); | |
return Enumerable.Empty<Task>(); | |
} | |
protected override void Dispose(bool disposing) | |
{ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment