anonyme methode in ConsoleTask

This commit is contained in:
test 2019-05-03 15:44:56 +02:00
parent e00f16b679
commit 782a6da74e
1 changed files with 23 additions and 8 deletions

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@ -11,21 +12,38 @@ namespace ConsoleAppTasks
{
static void Main(string[] args)
{
//var t = new Task(DoIt);
var t = new Task(DoIt);
t.Start();
int i = 4;
int y = 0;
//anonyme methode
var t = new Task(() =>
{
Thread.Sleep(2000);
Console.WriteLine("2");
y = 2 * i;
});
t.Start();
i = 99;
t.Wait();
Console.WriteLine(y); //198
/*
for (int i = 0; i < 999; i++)
{
Console.WriteLine("-");
Thread.Sleep(200);
}
*/
Console.ReadLine(); //wait for close
}
@ -37,10 +55,7 @@ namespace ConsoleAppTasks
{
Console.WriteLine("+");
Thread.Sleep(500);
}
}
}
}
}