Skip to content

Instantly share code, notes, and snippets.

@danielmarbach
danielmarbach / AnExample.cs
Last active October 26, 2020 10:55
RavenMigrations Async
namespace ServiceControl.Migrations
{
using System;
using System.Threading.Tasks;
using Raven.Abstractions;
using Raven.Abstractions.Data;
using ServiceBus.Management.Infrastructure.Settings;
using ServiceControl.Contracts.Operations;
using ServiceControl.MessageFailures;
@danielmarbach
danielmarbach / Handler.cs
Last active October 11, 2017 07:41
Example sync timeouts
namespace Server
{
public class Handler : IHandleMessages<SynchroniseSite>
{
public IProvideSites SiteProvider { get; set; }
public async Task Handle(SynchroniseSite message, IMessageHandlerContext context)
{
try
{
List<Data> data = new List<Data>();
@danielmarbach
danielmarbach / ContinueWithAllocations.cs
Last active December 19, 2016 23:59
ContinueWith Micro Benchmark
[Config(typeof(Config))]
public class ContinueWithAllocations
{
private class Config : ManualConfig
{
public Config()
{
Add(new MemoryDiagnoser());
}
}
@danielmarbach
danielmarbach / Error.xml
Created September 21, 2016 06:59
Myget Internal Server Error
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code/>
<m:message xml:lang="en-US">An error occurred while processing this request.</m:message>
<m:innererror>
<m:message>
Exception has been thrown by the target of an invocation.
</m:message>
<m:type>System.Reflection.TargetInvocationException</m:type>
<m:stacktrace>
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
[user]
email = daniel.marbach@openplace.net
name = danielmarbach
[merge]
tool = kdiff3
[diff]
guitool = kdiff3
[core]
autocrlf = False
editor = \"C:/Program Files (x86)/GitExtensions/GitExtensions.exe\" fileeditor
@danielmarbach
danielmarbach / MultiProducerConcurrentDispatcher.cs
Created October 17, 2016 15:44
MultiProducerConcurrentDispatcher
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace PushCollection
{
@danielmarbach
danielmarbach / TaskExtensions.cs
Last active November 29, 2016 06:45
TaskExtensions For Dennis
public static class TaskExtensions
{
public static Task<TResult> WaitWithCancellation<TResult>(this Task<TResult> task, CancellationToken token = default(CancellationToken))
{
var tcs = new TaskCompletionSource<TResult>();
var registration = token.Register(s =>
{
var source = (TaskCompletionSource<TResult>) s;
source.TrySetCanceled();
}, tcs);
@danielmarbach
danielmarbach / Program.cs
Created February 13, 2017 22:27
RabbitMQ tryouts
class Program
{
private static int numberOfMessages;
static void Main(string[] args)
{
File.Delete("./sync.txt");
File.Delete("./async.txt");
numberOfMessages = 1000;
@danielmarbach
danielmarbach / AsyncSandbox.cs
Created September 28, 2017 20:40
Ardalis Blog
using System;
using System.Diagnostics;
using System.Threading.Tasks;
namespace AsyncSandbox
{
class Program
{
static async Task Main(string[] args)
{
using System;
using System.Threading;
using System.Threading.Tasks;
namespace test
{
class Program
{
static async Task Main(string[] args)
{