##// END OF EJS Templates
working version of diagnostics logging
working version of diagnostics logging

File last commit:

r36:313f708a50e9 diagnostics
r37:c2c043520724 diagnostics
Show More
AsyncPool.cs
50 lines | 1.3 KiB | text/x-csharp | CSharpLexer
cin
initial log capabilities
r35 using Implab.Diagnostics;
cin
refactoring
r25 using System;
using System.Threading;
namespace Implab.Parallels {
/// <summary>
/// Класс для распаралеливания задач.
/// </summary>
/// <remarks>
/// Используя данный класс и лямда выражения можно распараллелить
/// вычисления, для этого используется концепция обещаний.
/// </remarks>
public static class AsyncPool {
public static Promise<T> Invoke<T>(Func<T> func) {
var p = new Promise<T>();
cin
improved log concept
r36 var caller = TraceContext.Current;
cin
refactoring
r25
ThreadPool.QueueUserWorkItem(param => {
cin
improved log concept
r36 TraceLog.Transfer(caller);
cin
refactoring
r25 try {
cin
Implemented interllocked queue...
r14 p.Resolve(func());
cin
refactoring
r25 } catch(Exception e) {
p.Reject(e);
}
});
return p;
cin
Implemented interllocked queue...
r14 }
public static Promise<T> InvokeNewThread<T>(Func<T> func) {
var p = new Promise<T>();
cin
improved log concept
r36 var caller = TraceContext.Current;
cin
initial log capabilities
r35
cin
Implemented interllocked queue...
r14 var worker = new Thread(() => {
cin
improved log concept
r36 TraceLog.Transfer(caller);
cin
Implemented interllocked queue...
r14 try {
p.Resolve(func());
} catch (Exception e) {
p.Reject(e);
}
});
worker.IsBackground = true;
worker.Start();
return p;
cin
refactoring
r25 }
}
}