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
async void Main() | |
{ | |
try | |
{ | |
await FooAsync().AsyncTrace(); | |
} | |
catch(Exception ex) | |
{ | |
ex.FullTrace().Dump(); | |
} |
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
public class Deferral : IDisposable | |
{ | |
private TaskCompletionSource<object> _completionSource = new TaskCompletionSource<object>(); | |
~Deferral() | |
{ | |
Dispose(false); | |
} | |
public void Dispose() |
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.Collections.Generic; | |
using System.Collections.ObjectModel; | |
using System.Threading; | |
namespace WpfApplication1 | |
{ | |
public class AsyncObservableCollection<T> : ObservableCollection<T> | |
{ | |
private readonly SynchronizationContext _synchronizationContext = SynchronizationContext.Current; |
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
void Main() | |
{ | |
var pb = new PictureBox { Image = Image.FromFile(@"D:\tmp\dotnet.png") }; | |
bool down = false; | |
Cursor dragCursor = null; | |
pb.MouseDown += (sender, e) => down = true; | |
pb.MouseUp += (sender, e) => { down = false; dragCursor = null; }; | |
pb.MouseMove += (sender, e) => | |
{ | |
if (down) |
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.Linq; | |
using System.Net; | |
using System.Text; | |
using Sharebox.Utils.Collections; | |
namespace Sharebox.Communication | |
{ | |
class BasicAuthenticationModule : IAuthenticationModule | |
{ |
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.Threading; | |
namespace Utils.Threading | |
{ | |
/// <summary> | |
/// A cancellable replacement for Thread.Sleep | |
/// </summary> | |
public static class Sleeper | |
{ |
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 NUnit.Framework; | |
namespace MyLibrary.Tests.XEnumerableTests | |
{ | |
[TestFixture] | |
class FullOuterJoinTests | |
{ | |
[Test] | |
public void FullOuterJoin_Throws_If_Argument_Null() |
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; | |
namespace System.Runtime.CompilerServices | |
{ | |
[AttributeUsageAttribute(AttributeTargets.Parameter, Inherited = false)] | |
public sealed class CallerMemberNameAttribute : Attribute | |
{ | |
} | |
[AttributeUsageAttribute(AttributeTargets.Parameter, Inherited = false)] | |
public sealed class CallerFilePathAttribute : Attribute |
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
void Main() | |
{ | |
var array = new byte[10000000]; | |
var initBlk = new InitblkMemoryHelper(); | |
var loop = new LoopMemoryHelper(); | |
// First run for JIT warmup and type initialization | |
initBlk.Memset(array, 0, array.Length, 42); | |
loop.Memset(array, 0, array.Length, 42); |
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
// Solution for James Michael Hare's anagram challenge (http://geekswithblogs.net/BlackRabbitCoder/archive/2015/07/28/little-puzzlersndashlist-all-anagrams-for-a-word.aspx) | |
// Run in LinqPad, adding a reference to Microsoft.Experimental.Collections | |
void Main() | |
{ | |
string path = @"D:\tmp\words.txt"; | |
var dict = new MultiValueDictionary<string, string>(); | |
foreach (var word in File.ReadLines(path)) | |
{ | |
dict.Add(new string(word.OrderBy(c => c).ToArray()), word); | |
} |