Skip to content

Instantly share code, notes, and snippets.

View maxcherednik's full-sized avatar

Maxim Cherednik maxcherednik

View GitHub Profile
class UberQueue<T>
{
private readonly IAsyncQueue<T>[] _queues;
private readonly Dictionary<Task<T>, IAsyncQueue<T>> _dequeuedItems = new Dictionary<Task<T>, IAsyncQueue<T>>();
public UberQueue(IAsyncQueue<T>[] queues)
{
_queues = queues;
}
class UberQueue<T>
{
private readonly IAsyncQueue<T>[] _queues;
private List<Task<T>> _dequeTasks;
public UberQueue(IAsyncQueue<T>[] queues)
{
_queues = queues;
}

Driver: Asp.net core framework usage is built around their own DI container implementation. Even though the implementation is rather limited compared to such veteran like Autofac, it is still built on the same principles and it is just enough for a modern application.

What is the problem then? Asp.net core is still rather young framework. Its primary focus is around the web aspect of the application server. It is nearly never enough. There is also a need for a background processing. The documentation guides us towards so-called Hosted services. Even though there is nothing wrong with the Hosted services themselves, the proposed approach is rather low-level and as a result error prone.

Lets take a look into this [examp

@maxcherednik
maxcherednik / *.cs
Created January 26, 2017 07:37
Actor example
using System;
using System.Collections.Generic;
using System.Linq;
using Akka.Actor;
using Akka.Event;
using Akka.Util.Internal;
namespace Akka.Shared
{
public class WidgetManagerActor : ReceiveActor
@maxcherednik
maxcherednik / gist:11048870
Created April 18, 2014 15:05
Cpu throttler
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
namespace AsyncThrottler
{
class Program
{
private static long _currentTaskNumber;