Skip to content

Instantly share code, notes, and snippets.

@distantcam
distantcam / SequentialWhenAll.cs
Last active February 3, 2016 09:00
An example using `Task.WhenAll` that runs all the tasks on the same thread.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
class Program
{
static void Main()
{
using System;
using System.Threading.Tasks;
class Program
{
static void Main()
{
Util.Method(() => ActionMethod());
Util.Method(ActionMethod); // Error CS0121 The call is ambiguous between the following methods or properties: 'Util.Method(Action)' and 'Util.Method(Func<Task>)'
}
@distantcam
distantcam / CUI.cs
Last active February 14, 2017 04:54
CUI - A simple Console UI
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using static System.Console;
using static System.ConsoleColor;
namespace CUI
{
public class ConsoleApplication<TScreen>
using System.ComponentModel;
using System.Linq;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes.Exporters;
using BenchmarkDotNet.Running;
[MemoryDiagnoser]
[MarkdownExporter]
public class PropertyChangedArgBenchmarks
{
@distantcam
distantcam / SimpleConfig.cs
Created October 12, 2017 08:57
Simple config class
public static class SimpleConfig
{
static string configFilePath;
public static void InitializeInLocalApplicationData(string name)
{
Initialize(Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
name,
"config.xml"
@distantcam
distantcam / Sample.csproj
Created October 19, 2017 03:27
Example new project
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net462</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<DebugType>full</DebugType>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
@distantcam
distantcam / JobHelper.cs
Last active August 17, 2023 15:54
Unity Job system with async
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Unity.Jobs;
public static class JobHelper
{
using Unity.Entities;
using Unity.Jobs;
public abstract class CompositeParallelJobSystem<T1, T2> : JobComponentSystem
where T1 : struct, IJobParallelFor
where T2 : struct, IJobParallelFor
{
protected ComponentGroup group;
protected abstract ComponentGroup CreateGroup();
@distantcam
distantcam / extensions.json
Created March 28, 2019 07:15
Presentation settings for vscode
{
"recommendations": [
"saviorisdead.theme-githubcleanwhite",
"evilz.vscode-reveal"
]
}