How Interlocked Ensures Atomicity

2025-03-18 This article was created with the assistance of ChatGPT Low-Level CPU Instructions: The Interlocked class uses atomic CPU instructions that are executed as indivisible units. These CPU instructions, like Compare-and-Swap (CAS) or Test-and-Set, ensure that the operation is performed entirely or not at all, with no interference from other threads. These instructions are implementedContinue reading “How Interlocked Ensures Atomicity”

Understanding Stack Frames in .NET

2025-03-18 This article was created with the assistance of ChatGPT What is a Stack Frame? A stack frame is a data structure created on the call stack whenever a method is invoked. It holds all the necessary information for a method to execute and return correctly. Each thread in a .NET application has its ownContinue reading “Understanding Stack Frames in .NET”

Solved: The destination thread no longer exists exception – C#

2016-11-08 You will get System.ComponentModel.InvalidAsynchronousStateException (The destination thread no longer exists.) if a UI component gets disposed or the UI thread EXITs while a different thread is in the middle of invoking a change on the same UI component. This usually happens when a user closes a window (form) that has been updated by aContinue reading “Solved: The destination thread no longer exists exception – C#”

Using multiple versions of Entity Framework in the same solution

2016/07/20 Using multiple versions of Entity framework by different projects within the same solution. I had to develop a pilot project to use Entity framework (EF) 6.0 inside the solution that already has other projects that refers to EF 4.4. While debugging I received this error: Could not load file or assembly ‘EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’Continue reading “Using multiple versions of Entity Framework in the same solution”

SQL Server data types explained with .net data types

2016/07/19 Source / Reference : Msdn Member name Description BigInt Int64. A 64-bit signed integer. Binary Array of type Byte. A fixed-length stream of binary data ranging between 1 and 8,000 bytes. Bit Boolean. An unsigned numeric value that can be 0, 1, or null. Char String. A fixed-length stream of non-Unicode characters ranging betweenContinue reading “SQL Server data types explained with .net data types”

SQL to Generate C# Properties from SQL Table Columns

2016/07/15 Below SQL will generate C# properties for all columns in a table in SQL server. Notes: You will have to fix datatypes that are not interchangeable between SQL and C#. You will also have to polish property names if you follow a different naming convention for column names. The query below automatically renames someContinue reading “SQL to Generate C# Properties from SQL Table Columns”

C# Reflection Code to Search Objects for Fields Properties and Methods and Get Values

2016-07-06 Code below will search for a given named property, field, or method inside a given object. It will search in below order: Properties Fields Methods It will continue to search until it finds a match that holds or returns (for methods) a non-null value. E.g. If you searched for “Name” and if there is a propertyContinue reading “C# Reflection Code to Search Objects for Fields Properties and Methods and Get Values”