Skip to content

Instantly share code, notes, and snippets.

View Cassandra-d's full-sized avatar

Artem Cassandra-d

  • Saint-Petersburg
View GitHub Profile
@Cassandra-d
Cassandra-d / Allocations and objects
Last active April 15, 2020 19:50
How to get number of allocated segments with ETW and enumerate objects on heap. Requires DebugDiagHelpers, Microsoft.Diagnostics.Runtime and Microsoft.Diagnostics.Tracing.TraceEvent nuget packages
using Microsoft.Diagnostics.Tracing.Parsers;
using Microsoft.Diagnostics.Tracing.Session;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Diagnostics.Runtime;
static async Task Main(string[] args)
{
var host = "http://localhost:57703/";
var sync = new Uri(host + "sync");
var async = new Uri(host + "async");
List<Task<WebResponse>> tasks = new List<Task<WebResponse>>();
for (int i = 0; i < 1000; i++)
{
@Cassandra-d
Cassandra-d / ManualResetThreads.cs
Created November 2, 2017 12:12
Example of waiting for several threads to complete
public class Program
{
private static Thread one;
private static Thread two;
private static Thread three;
private static HybridDictionary events;
static void Main(string[] args)
{
@Cassandra-d
Cassandra-d / efsavechanges.cs
Created October 26, 2017 08:01
Example of changed entity state
public class Context : DbContext
{
public DbSet<EntOne> Ones { get; set; }
public DbSet<EntTwo> Twos { get; set; }
public Context(DbContextOptions<Context> options)
: base(options)
{
}