Mercurial > pub > ImplabNet
comparison Implab/Parallels/AsyncPool.cs @ 36:313f708a50e9 diagnostics
improved log concept
author | cin |
---|---|
date | Tue, 15 Apr 2014 02:00:09 +0400 |
parents | 2880242f987a |
children | fe33f4e02ad5 |
comparison
equal
deleted
inserted
replaced
35:2880242f987a | 36:313f708a50e9 |
---|---|
12 /// </remarks> | 12 /// </remarks> |
13 public static class AsyncPool { | 13 public static class AsyncPool { |
14 | 14 |
15 public static Promise<T> Invoke<T>(Func<T> func) { | 15 public static Promise<T> Invoke<T>(Func<T> func) { |
16 var p = new Promise<T>(); | 16 var p = new Promise<T>(); |
17 var caller = LogContext.Current; | 17 var caller = TraceContext.Current; |
18 | 18 |
19 ThreadPool.QueueUserWorkItem(param => { | 19 ThreadPool.QueueUserWorkItem(param => { |
20 Log.Transfer(caller); | 20 TraceLog.Transfer(caller); |
21 try { | 21 try { |
22 p.Resolve(func()); | 22 p.Resolve(func()); |
23 } catch(Exception e) { | 23 } catch(Exception e) { |
24 p.Reject(e); | 24 p.Reject(e); |
25 } | 25 } |
29 } | 29 } |
30 | 30 |
31 public static Promise<T> InvokeNewThread<T>(Func<T> func) { | 31 public static Promise<T> InvokeNewThread<T>(Func<T> func) { |
32 var p = new Promise<T>(); | 32 var p = new Promise<T>(); |
33 | 33 |
34 var caller = LogContext.Current; | 34 var caller = TraceContext.Current; |
35 | 35 |
36 var worker = new Thread(() => { | 36 var worker = new Thread(() => { |
37 Log.Transfer(caller); | 37 TraceLog.Transfer(caller); |
38 try { | 38 try { |
39 p.Resolve(func()); | 39 p.Resolve(func()); |
40 } catch (Exception e) { | 40 } catch (Exception e) { |
41 p.Reject(e); | 41 p.Reject(e); |
42 } | 42 } |