Skip to content

Latest commit

 

History

History
46 lines (30 loc) · 1.28 KB

README.md

File metadata and controls

46 lines (30 loc) · 1.28 KB

Schedule

Schedulers for asynchronous execution in a separate thread.

Features

  • Non-blocking execution
  • Non-competing thread-safe execution in a single or multiple threads
  • Circular buffer of tasks implementing LRU or MRU cache
  • Single-threaded timer
  • Batch execution with delay

Status

Install-Package Schedule

GitHub Workflow Status (with event) GitHub GitHub

Sample

// Guaranteed execution in a single thread for thread-safe access to context variables

var scheduler = new BackgroundRunner();
var x = scheduler.Send(() => Environment.CurrentManagedThreadId).Task.Result;
var y = Task.Run(() => scheduler.Send(() => Environment.CurrentManagedThreadId).Task.Result).Result;

Assert.Equal(x, y);

// Thread-safe single-threaded timer 

var num = new Random();
var collection = new List<int>();
var scheduler = new LoopScheduler();

Observable.Interval(span, scheduler).Subscribe(o => collection.Add(num.Next()));

Roadmap

Automatically calculate CPU load and spread work across cores.