Tag Archives

Archive of posts published in the tag: C#

.NET Inside Out Part 9 — Generating Func from a bunch of bytes in C# revisited

This is the ninth part of the .NET Inside Out series. For your convenience you can find other parts in the table of contents in Part 1 – Virtual and non-virtual calls in C# We know how to generate delegate from a byte…

Async Wandering Part 5 — Catching exceptions from async void

This is the fifth part of the Async Wandering series. For your convenience you can find other parts in the table of contents in Part 1 – Why creating Form from WinForms in unit tests breaks async? Last time we saw how to…

Custom memory allocation in C# Part 11 — Benchmarking UnsafeList

This is the eleventh part of the Custom memory allocation series. For your convenience you can find other parts in the table of contents in Part 1 — Allocating object on a stack I presented some results suggesting that UnsafeList is faster than…

Custom memory allocation in C# Part 10 — Hijacking new in .NET Core

This is the tenth part of the Custom memory allocation series. For your convenience you can find other parts in the table of contents in Part 1 — Allocating object on a stack I had .NET Core 2.1.103 x64 installed and I wanted…

Custom memory allocation in C# Part 9 — Hijacking new in x64

This is the ninth part of the Custom memory allocation series. For your convenience you can find other parts in the table of contents in Part 1 — Allocating object on a stack We already hijacked new in C#. Last time we did…

Exception propagation in WinForms

Let’s start with the following code: using System; using System.Windows.Forms; class Program1 { [STAThread] static void Main() { var form = new Form(); form.Load += (sender, e) => throw new Exception(); try { Application.Run(form); } catch(Exception e) { MessageBox.Show(“This doesn’t execute”); } finally…

Trivial ScheduledThreadPoolExecutor in C#

Today we are going to implement trivial ScheduledExecutorService in C#. Introduction We want to have a thread pool of fixed size which we can use to execute three types of tasks: One time tasks Tasks with fixed delay between executions Tasks with fixed…

ILP Part 50 — MST, vertex cover and edge cover

This is the fiftieth part of the ILP series. For your convenience you can find other parts in the table of contents in Part 1 – Boolean algebra Today we are going to solve three graph problems: vinimum spanning tree, vertex cover and…

Custom memory allocation in C# Part 8 — Unsafe list in .NET Core x64

This is the eighth part of the Custom memory allocation series. For your convenience you can find other parts in the table of contents in Part 1 — Allocating object on a stack Today we are going to revisit an Unsafe list example…

Reordered code after compilation

Can one line of code in C# JIT compile into two different blocks of code in the same program? This sounds a little tricky but in fact is very easy and happens pretty often. Consider the following code: using System; namespace Reordering {…

Custom memory allocation in C# Part 7 — Stack allocation once again

This is the seventh part of the Custom memory allocation series. For your convenience you can find other parts in the table of contents in Part 1 — Allocating object on a stack We know how to allocate object on a stack, however,…

Concurrency Part 6 – Abandoned mutex

This is the sixth part of the Concurrency series. For your convenience you can find other parts in the table of contents in Part 1 – Mutex performance in .NET Let’s start with the following code: using System; using System.Threading; namespace AbandonedMutex {…

Concurrency Part 5 – WinAPI mutex

This is the fifth part of the Concurrency series. For your convenience you can find other parts in the table of contents in Part 1 – Mutex performance in .NET Last time we called WinAPI through P/Invoke, today we are going to call…

Concurrency Part 4 – .NET with P/Invoke

This is the fourth part of the Concurrency series. For your convenience you can find other parts in the table of contents in Part 1 – Mutex performance in .NET We have already seen a mutex in C# but last time it happened…

Concurrency Part 1 – Mutex performance in .NET

This is the first part of the Concurrency series. For your convenience you can find other parts using the links below: Part 1 — Mutex performance in .NET Part 2 — Java file lock Part 3 — Java mutex via JNI Part 4…

ILP Part 49 — Deadline24 2018 – Flow

This is the forty ninth part of the ILP series. For your convenience you can find other parts in the table of contents in Part 1 – Boolean algebra Today we solve the task B from Deadline24 2018 edition. Sewage system Introduction Beetlejumpers…

ILP Part 48 — Shapes and colors

This is the forty eighth part of the ILP series. For your convenience you can find other parts in the table of contents in Part 1 – Boolean algebra You are given board with thirty rows and fifteen columns. For each cell you…

.NET Inside Out Part 8 — Handling Stack Overflow Exception in C# with VEH

This is the eighth part of the .NET Inside Out series. For your convenience you can find other parts in the table of contents in Part 1 – Virtual and non-virtual calls in C# If you are interested in the topic see the…

DLL Injection Part 7 — Injecting Java code

This is the seventh part of the DLL Injection series. For your convenience you can find other parts in the table of contents in Part 1 – Registry We already injected native code into target, managed code into default application domain, and managed…

.NET Inside Out Part 7 — Generating Func from a bunch of bytes in C#

This is the seventh part of the .NET Inside Out series. For your convenience you can find other parts in the table of contents in Part 1 – Virtual and non-virtual calls in C# In Capturing thread creation to catch exceptions we generated…