Skip to content

Instantly share code, notes, and snippets.

@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 / 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
{
[user]
email = [email protected]
name = danielmarbach
[merge]
tool = kdiff3
[diff]
guitool = kdiff3
[core]
autocrlf = False
editor = \"C:/Program Files (x86)/GitExtensions/GitExtensions.exe\" fileeditor
@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)
@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 / 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 / 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 / gist:9787441
Last active August 29, 2015 13:57
Mapping
namespace Here
{
public class Root
{
public string Foo { get; set; }
public Child Child { get; set; }
@danielmarbach
danielmarbach / AssemblyInfo.cs
Created July 22, 2013 17:56
My InMemory approach for unit testing and acceptance testing with NServiceBus which uses custom IBus, FluentAssertions and NUnit actions
[assembly: WithBus]
@danielmarbach
danielmarbach / MoqToFakeItEasy.DotSettings
Last active July 3, 2024 18:26
Structural Search and Replace Pattern for Migration from Moq to FakeItEasy with Resharper
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=23B254B63645A7449313D9A6F88A5C0C/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=23B254B63645A7449313D9A6F88A5C0C/Comment/@EntryValue">Replace Mock Field with FakeItEasy</s:String>
<s:Boolean x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=23B254B63645A7449313D9A6F88A5C0C/CustomPatternPlaceholder/=fieldName/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/StructuralSearch/Pattern/=23B254B63645A7449313D9A6F88A5C0C/CustomPatternPlaceholder/=fieldName/Properties/=CaseSensitive/@EntryIndexedValue">True</s:String>
<s:String x:Key="/Default/PatternsAndTempla