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”

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”

Using Regular Expressions With Find And Replace In .Net IDE

06-06-2012 Use any regular expression to make your match. Then use {} pairs to define blocks of the search string you want to use in the Replaced string. Example: following find and replace strings will replace all occurrences ” report(number) ” to  ” // report – number ” in the following sample code. Sample CodeContinue reading “Using Regular Expressions With Find And Replace In .Net IDE”

How to Implement a Background Worker Thread that Supports Cancellation (How to Stop A Background Thread)

30-05-2012 The background worker in .net provides a method CancelAsync() to cancel a background worker. However, calling this method will not stop a worker thread there has to be several things you have to implement before. 1. First of all, for a BackgroundWorker to respond to a CancelAsync, you must set the WorkerSupportsCancellation flag. 2.Continue reading “How to Implement a Background Worker Thread that Supports Cancellation (How to Stop A Background Thread)”

ASP.NET – AutoPostBack : What is AutoPostBack and How AutoPostBack Works

2008-12-26 Today I was experimenting on a grid view where I was trying to select multiple rows of the grid view using a check box column. I wrote some code in the CheckedChanged of checkbox but then I found that the code was not executed when the state of the checkbox is changed. So IContinue reading “ASP.NET – AutoPostBack : What is AutoPostBack and How AutoPostBack Works”