- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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();
Advertisements