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.Concurrent; | |
using System.Threading.Channels; | |
var channel = Channel.CreateUnbounded<int>(); | |
var syncContext = new SingleThreadedSyncContext(); | |
syncContext.Post(async _ => | |
{ | |
await foreach (var item in channel.Reader.ReadAllAsync()) |
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
namespace Noseratio; | |
/// <summary> | |
/// Single thread event loop scheduler, based on Rx <seealso cref="EventLoopScheduler"/> | |
/// but with added SynchronizationContext and TPL TaskScheduler API | |
/// https://gist.github.com/noseratio/22a291e1d69f6d1cea547623ad9c9147 | |
/// </summary> | |
public sealed partial class EventLoopThreadScheduler : | |
TaskScheduler, | |
IScheduler, |
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; | |
using System.Numerics; | |
namespace Common | |
{ | |
/// <summary> | |
/// Arbitrary precision decimal. | |
/// All operations are exact, except for division. Division never determines more digits than the given precision. | |
/// Source: https://gist.github.com/JcBernack/0b4eef59ca97ee931a2f45542b9ff06d | |
/// Based on https://stackoverflow.com/a/4524254 |