Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace TPL_part_1_creating_simple_tasks
- {
- class Program
- {
- static void Main(string[] args)
- {
- //Action delegate
- Task task1 = new Task(new Action(HelloConsole));
- //anonymous function
- Task task2 = new Task(delegate
- {
- HelloConsole();
- });
- //lambda expression
- Task task3 = new Task(() => HelloConsole());
- task1.Start();
- task2.Start();
- task3.Start();
- Console.WriteLine("Main method complete. Press any key to finish.");
- Console.ReadKey();
- }
- static void HelloConsole()
- {
- Console.WriteLine("Hello Task");
- }
- }
- }
- //http://www.c-sharpcorner.com/UploadFile/f9f215/parallel-programming-part-1-introducing-task-programming-l/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement