
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Different ways to start a Task in C#
To start a task in C#, follow any of the below given ways.
Use a delegate to start a task.
Task t = new Task(delegate { PrintMessage(); }); t.Start();
Use Task Factory to start a task.
Task.Factory.StartNew(() => {Console.WriteLine("Welcome!"); });
You can also use Lambda.
Task t = new Task( () => PrintMessage() ); t.Start();
- Related Articles
- How to start the specific task of the task scheduler using PowerShell?
- How to automatically start and stop an Async task in Kotlin?
- Different ways to overload a method in Java
- Different ways to clear a list in Python
- Explain different ways to induce current in a coil.
- Different ways to concatenate Strings in Java
- Different ways to create Objects in Java
- Different Ways to Add Parentheses in C++
- How to create a Scheduled task with a task scheduler using PowerShell?
- Different ways of Reading a file in C#
- Extending a list in Python (5 different ways)
- 5 different ways to create objects in Java
- Different ways to print exception messages in Java
- Three Different ways to calculate factorial in C#
- Different ways to create an object in java?

Advertisements