Skip to content

Instantly share code, notes, and snippets.

View negativeeddy's full-sized avatar

Ben Williams negativeeddy

View GitHub Profile
@negativeeddy
negativeeddy / Task Exception Policy Test.cs
Created February 18, 2016 14:31
The is a simple c# console app that demonstrates various behaviors when .NET Tasks do or do not have their exceptions observed.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace UnobservedExceptions
{
// NOTES:
@negativeeddy
negativeeddy / Task Exception Await vs Forget.cs
Last active February 18, 2016 14:34
TPL exception behavior test. This demonstrates exception behavior based on whether the Task is ignored or awaited deep inside a callstack.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace async_exception_test
{
class Program
{
@negativeeddy
negativeeddy / clean-devfolders.ps1
Last active September 21, 2016 20:02
This is a powershell script that will recursively remove all the obj, bin, and packages directories from the current directory and its children.
get-childitem -Directory -Recurse | where-object {$_.Name -eq 'bin' -or $_.Name -eq 'obj' -or $_.Name -eq 'packages'} | Remove-Item -Force -Recurse
@negativeeddy
negativeeddy / Settings.cs
Last active September 30, 2016 20:32
This is how I do strongly typed application settings. Either pass the Dictionary in if provided by the system, or serialize/deserialize to disk as needed.
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace NegativeEddy.Settings
{
public class ApplicationSettings
{
Dictionary<string, object> _settingsBag;
public void Load()
@negativeeddy
negativeeddy / main.cs
Created December 8, 2017 22:38
async Main method in C#
static async Task Main(string[] args)
{
HttpClient client = new HttpClient();
string result = await client.GetStringAsync("http://www.bing.com");
Console.WriteLine(result);
}
@negativeeddy
negativeeddy / AsyncVsAbort.cs
Created August 27, 2018 16:25
code snippet for blog regarding Threading Abort and async/await
using System;
using System.Threading;
using System.Threading.Tasks;
namespace AsyncVsAbort
{
class Program
{
static void Main(string[] args)
{
@negativeeddy
negativeeddy / parameters.template.json
Created June 25, 2019 15:42
Virtual Assistant parameters template that uses free or least expensive resources
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appInsightsLocation": {
"value": "westus2"
},
"contentModeratorLocation": {
"value": "westus"