Part 88 ThreadStart delegate
Text version of the video http://csharp-video-tutorials.blogspo... Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help. / @aarvikitchen5572 Slides http://csharp-video-tutorials.blogspo... All C# Text Articles http://csharp-video-tutorials.blogspo... All C# Slides http://csharp-video-tutorials.blogspo... All Dot Net and SQL Server Tutorials https://www.youtube.com/user/kudvenka... In this video we will discuss the ThreadStart delegate. This is continuation to Part 87. Please watch Part 87 before proceeding. Let us understand the purpose of ThreadStart delegate with an example. using System; using System.Threading; namespace ThreadStartDelegateExample { class Program { public static void Main() { Thread T1 = new Thread(Number.PrintNumbers); T1.Start(); } } class Number { public static void PrintNumbers() { for (int i = 1; i [= 10; i++) { Console.WriteLine(i); } } } } In the example above to create a THREAD, we created an instance of Thread class and to it's constructor we have passed the name of the function that we want the thread to execute. Thread T1 = new Thread(Number.PrintNumbers); We can rewrite the above line using ThreadStart delegate as shown below. Thread T1 = new Thread(new ThreadStart(Number.PrintNumbers)); Why a delegate need to be passed as a parameter to the Thread class constructor? The purpose of creating a Thread is to execute a function. A delegate is a type safe function pointer, meaning it points to a function that the thread has to execute. In short, all threads require an entry point to start execution. Any thread you create will need an explicitly defined entry point i.e a pointer to the function where they should begin execution. So threads always require a delegate. In the code below, we are not explicitly creating the ThreadStart delegate, then how is it working here? Thread T1 = new Thread(Number.PrintNumbers); It's working in spite of not creating the ThreadStart delegate explicitly because the framework is doing it automatically for us. We can also rewrite the same line using delagate() keyword as shown below. Thread T1 = new Thread(delegate() { Number.PrintNumbers(); }); We can also rewrite the same line using lambda expression as shown below. Thread T1 = new Thread(() =] Number.PrintNumbers()); Thread function need not be a static function always. It can also be a non-static function. In case of non-static function we have to create an instance of the class. An example is shown below. class Program { public static void Main() { Number number = new Number(); Thread T1 = new Thread(number.PrintNumbers); T1.Start(); } } class Number { public void PrintNumbers() { for (int i = 1; i [= 10; i++) { Console.WriteLine(i); } } }

Part 89 ParameterizedThreadStart delegate

Async and await in C# example

Portugal – Spanien Highlights | Achtelfinale, FIFA WM 2026 | sportstudio

Portugal vs. Spain Highlights FIFA World Cup 2026 | Sportschau

Penny Helps Sheldon Solve His Equation | The Big Bang Theory

Android 17 sucks. So I put Linux on a phone.

The French Do Not Care About Work

Morning Vibes ☀️ Chill Tracks To Lift Your Morning | Indie/Pop/Folk/Acoustic Playlist

80s Love Songs Playlist 🌤️ | Soft Rock Ballads & Classic Love Songs | Vol. 14 | Retro Rush FM

c# (Csharp) threading interview question:- What is thread,background thread and foreground thread ?

The Mountains Are Calling ⛰️ - An Indie/Folk/Pop Playlist | Vol. 1

4 Hours of Deep Focus Music for Studying - Concentration Music For Deep Thinking And Focus

The Day 18 Years Old Lionel Messi Substituted & SHOCKED The World

When Animals Surprise Photographers in the Sweetest Way! 😍

Adobe Is Completely F*cked.

The Untold Story of SSH

NGINX Explained - What is Nginx

C# multithreading 🧶

