Public LimitedConcurrencyLevelTaskScheduler(int maxDegreeOfParallelism) Creates a new instance with the specified degree of parallelism. Private int _delegatesQueuedOrRunning = 0 Indicates whether the scheduler is currently processing work items. Private readonly int _maxDegreeOfParallelism The maximum concurrency level allowed by this scheduler. Use our factory to run a set of tasks.įor (int outer = 0 outer _tasks = new LinkedList() // protected by lock(_tasks) TaskFactory factory = new TaskFactory(lcts) ĬancellationTokenSource cts = new CancellationTokenSource() Create a TaskFactory and pass it our custom scheduler. LimitedConcurrencyLevelTaskScheduler lcts = new LimitedConcurrencyLevelTaskScheduler(2) Create a scheduler that uses two threads. It then launches two sets of tasks and displays information about the task and the thread on which the task is executing. The following example creates a custom task scheduler that limits the number of threads used by the app.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |