-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
57 lines (54 loc) · 1.77 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TPL_csharp_sample
{
class Program
{
private delegate void DELG();
static void Main(string[] args)
{
System.Threading.Thread t1;
DELG d_it;
DELG d_tpl;
CLwork ow;
IAsyncResult iasync_it;
IAsyncResult iasync_tpl;
t1 = new System.Threading.Thread(
new System.Threading.ThreadStart(CLtime.start));
ow = new CLwork();
d_it = new DELG(() =>
{
Console.WriteLine(ow.m_work_it().ToString());
});
d_tpl = new DELG(() =>
{
Console.WriteLine(ow.m_work_tpl().ToString());
});
t1.Start();
iasync_it = d_it.BeginInvoke((async) =>
{
DELG dlg = (DELG)
((System.Runtime.Remoting.Messaging.AsyncResult)async).AsyncDelegate;
dlg.EndInvoke(async);
Console.WriteLine("fin du traitement itératif");
}, d_it);
iasync_tpl = d_tpl.BeginInvoke((async) =>
{
DELG dlg = (DELG)
((System.Runtime.Remoting.Messaging.AsyncResult)async).AsyncDelegate;
dlg.EndInvoke(async);
Console.WriteLine("fin du traitement tpl");
}, d_tpl);
while ((!iasync_it.IsCompleted))
{
Console.WriteLine("En cours de traitement..."); System.Threading.Thread.Sleep(1000);
Console.WriteLine(iasync_it.IsCompleted.ToString());
}
t1.Abort();
Console.Read();
}
}
}