77
1
using System;
2
using System.Threading;
3
using System.Threading.Tasks;
4
5
public class Program
6
{
7
public static void Main()
8
{
9
//DetachedTask();
10
//ParentWaitingForDetachedTask();
11
//CreatingAttachedChildTask();
12
PreventChildFromAttaching();
13
}
14
15
private static void DetachedTask()
16
{
17
var parentTask = Task.Factory.StartNew(() => {
18
Console.WriteLine("Parent task executing");
19
20
var childTask = Task.Factory.StartNew(() => {
21
Console.WriteLine("Child task executing");
22
Thread.SpinWait(500000);
23
Console.WriteLine("Child task completed");
24
});
Cached Result
Process started..
Worker #1234567890 - Total Worker Flight Time: 26
Worker #1234567890 - Worker Work Time Details: [Block Start: 12/30/1899 8:30:00 AM Block End: 12/30/1899 11:45:00 AM In-Out Count: 3] The worker is out of the block for more than 15 min
Worker #1234567890 - Total Worker Flight Time: 23
Worker #1234567890 - Worker Work Time Details: [Block Start: 12/30/1899 1:15:00 PM Block End: 12/30/1899 5:00:00 PM In-Out Count: 3] The worker is out of the block for more than 15 min
Summary
-------
Worker #1234567890 worked in block(s) 1, 2
Worker #1234567890 didn't work in block(s) 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
Worker #1234567891 - Total Worker Flight Time: 16
Worker #1234567891 - Worker Work Time Details: [Block Start: 12/2/1899 8:30:00 AM Block End: 12/2/1899 11:45:00 AM In-Out Count: 1] The worker is out of the block for more than 15 min
Worker #1234567891 - Total Worker Flight Time: 25
Worker #1234567891 - Worker Work Time Details: [Block Start: 12/3/1899 8:30:00 AM Block End: 12/3/1899 11:45:00 AM In-Out Count: 3] The worker is out of the block for more than 15 min
Worker #1234567891 - Total Worker Flight Time: 180
Worker #1234567891 - Worker Work Time Details: [Block Start: 12/4/1899 1:15:00 PM Block End: 12/4/1899 5:00:00 PM In-Out Count: 1] The worker is out of the block for more than 15 min
Worker #1234567891 - Total Worker Flight Time: 16
Worker #1234567891 - Worker Work Time Details: [Block Start: 12/5/1899 8:30:00 AM Block End: 12/5/1899 11:45:00 AM In-Out Count: 1] The worker is out of the block for more than 15 min
Worker #1234567891 - Total Worker Flight Time: 16
Worker #1234567891 - Worker Work Time Details: [Block Start: 12/6/1899 1:15:00 PM Block End: 12/6/1899 5:00:00 PM In-Out Count: 1] The worker is out of the block for more than 15 min
Summary
-------
Worker #1234567891 worked in block(s) 4, 5, 6, 7, 8, 9, 10, 11, 13, 14
Worker #1234567891 didn't work in block(s) 1, 2, 3, 12, 15
Process finished..
Worker #1234567890 - Total Worker Flight Time: 26
Worker #1234567890 - Worker Work Time Details: [Block Start: 12/30/1899 8:30:00 AM Block End: 12/30/1899 11:45:00 AM In-Out Count: 3] The worker is out of the block for more than 15 min
Worker #1234567890 - Total Worker Flight Time: 23
Worker #1234567890 - Worker Work Time Details: [Block Start: 12/30/1899 1:15:00 PM Block End: 12/30/1899 5:00:00 PM In-Out Count: 3] The worker is out of the block for more than 15 min
Summary
-------
Worker #1234567890 worked in block(s) 1, 2
Worker #1234567890 didn't work in block(s) 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
Worker #1234567891 - Total Worker Flight Time: 16
Worker #1234567891 - Worker Work Time Details: [Block Start: 12/2/1899 8:30:00 AM Block End: 12/2/1899 11:45:00 AM In-Out Count: 1] The worker is out of the block for more than 15 min
Worker #1234567891 - Total Worker Flight Time: 25
Worker #1234567891 - Worker Work Time Details: [Block Start: 12/3/1899 8:30:00 AM Block End: 12/3/1899 11:45:00 AM In-Out Count: 3] The worker is out of the block for more than 15 min
Worker #1234567891 - Total Worker Flight Time: 180
Worker #1234567891 - Worker Work Time Details: [Block Start: 12/4/1899 1:15:00 PM Block End: 12/4/1899 5:00:00 PM In-Out Count: 1] The worker is out of the block for more than 15 min
Worker #1234567891 - Total Worker Flight Time: 16
Worker #1234567891 - Worker Work Time Details: [Block Start: 12/5/1899 8:30:00 AM Block End: 12/5/1899 11:45:00 AM In-Out Count: 1] The worker is out of the block for more than 15 min
Worker #1234567891 - Total Worker Flight Time: 16
Worker #1234567891 - Worker Work Time Details: [Block Start: 12/6/1899 1:15:00 PM Block End: 12/6/1899 5:00:00 PM In-Out Count: 1] The worker is out of the block for more than 15 min
Summary
-------
Worker #1234567891 worked in block(s) 4, 5, 6, 7, 8, 9, 10, 11, 13, 14
Worker #1234567891 didn't work in block(s) 1, 2, 3, 12, 15
Process finished..