Synchronization Tutorials

One of the benefits of using multithreading in .NET is to improve the performance of our applications. We execute long running tasks in the background threads and make the UI thread idle to get the user's inputs. We share resources between multiple threads such as memory. If multiple threads will try to update the data at the same time, the memory get corrupted and ...

Continue Reading

WPF BackgroundWorker

To build more responsive WPF UI, we have to use multiple threads that can work in the background and update the UI when the work completed. But background threads can't access the objects created in the STA. Then how can we update the UI when the background threads completed their work?  WPF applications are based on Single Threaded Apartment Model (STA). Ob...

Continue Reading

C# Interface

C# Interface defines a group of related functionality. An interface defines only the definition of the functionality. All classes and structures which inherit from interface must implement the functionality defined in an interface. We can not create an instance of interface. In the interface declaration variable, we can only store the instance of the object that impleme...

Continue Reading

.NET Threading Interview Questions Series - Part 1

Q 1.  What is the difference between Process and Thread? A process is started when you start an Application. A process is a collection of resources like virtual address space, code, security contexts etc. A process can start multiple threads. Every process is start with a single thread called primary thread. You can create n number of threads in a process. Threads share...

Continue Reading

.NET Threading Interview Questions Series - Part 2

Q 21. What is the class hierarchy of wait handles? Q 22. What is ManualResetEvent and how it is different between AutoResetEvent? ManualResetEvent is also a synchronization mechanism similar to AutoResetEvent which works on bool variable. If the bool variable is false, it blocks the thread. If true, it unblocks the threads. ManualResetEvent provides the sa...

Continue Reading

C# Reflection Introduction

Reflection in C# is a big topic in itself. I'll summarize a little list of what you can do with reflection. Get currently executing assembly, load assembly, get assembly from type Get classes declared in assemblies Get methods, properties, fields, events, constructors declared in classes Check access modifiers of classes, properties, fields and me...

Continue Reading

C# Predicate

Predicate is a pre-built delegate in the .NET framework class library. Delegates are used to store method which has same parameters and return types as specify in the delegate type. Predicate is a generic delegate. It takes one parameter and returns a boolean value. Predicate delegate is used for check whether a parameter meets specify condition or not. ...

Continue Reading

C# Action

A delegate in C# represents a reference type that encapsulates a method. When we declare a delegate type we specify some parameters and a return type. We can only store those methods in delegates which has same parameters and same return type. Microsoft introduced some pre-built delegates so that we don't have to declare delegates every time. Action is one of the pre-b...

Continue Reading

C# Reflection - What is Assembly?

Assembly is the main unit in .NET applications. Assembly is a collection of types and its information. There are two types of assemblies: Executable files (EXE) Libraries (DLL) Both type of assemblies includes information about types and its members in its metadata. There are three ways to get Assembly instances: Geting assembly instance from type...

Continue Reading

C# Reflection - Getting Constructors

C# reflection Type class provides two methods for getting the constructors in any Type. GetConstructors() //Returns all the constructors GetConstructor() //Returns only the specific constructor with match your given criteria. By default, all the above methods returns public constructors of a Type. To get the private, protected, and static constructors you have to u...

Continue Reading

Join our newsletter and get an occasional email with a technology and dotnetpattern.com news update.