2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-12-14 08:50:23 +00:00

test complete

This commit is contained in:
2025-11-08 12:36:22 +03:00
parent fc943c8a36
commit e2e4ac90bc
11 changed files with 238 additions and 121 deletions

View File

@@ -50,6 +50,14 @@ public class AsyncBag<T> : AsyncReply, IAsyncBag
public AsyncBag<T> Then(Action<T[]> callback)
{
//if (!sealedBag && !resultReady)
// throw new Exception("Not sealed");
Timeout(6000, () =>
{
Console.WriteLine("Timeout " + count + this.Result);
});
base.Then(new Action<object>(o => callback((T[])o)));
return this;
}
@@ -99,7 +107,7 @@ public class AsyncBag<T> : AsyncReply, IAsyncBag
count++;
if (count == replies.Count)
Trigger(results);
});
}).Error(e => TriggerError(e));
}
else
{

View File

@@ -86,10 +86,12 @@ public class AsyncReply
return result;
}
//int timeoutMilliseconds = 0;
public AsyncReply Timeout(int milliseconds, Action callback = null)
{
//timeoutMilliseconds = milliseconds;
Task.Delay(milliseconds).ContinueWith(x =>
{
if (!resultReady && exception == null)
@@ -131,8 +133,15 @@ public class AsyncReply
}
public AsyncReply Then(Action<object> callback)
protected string codePath, codeMethod;
protected int codeLine;
public AsyncReply Then(Action<object> callback, [CallerMemberName] string methodName = null, [CallerFilePath] string filePath = null, [CallerLineNumber] int lineNumber = 0)
{
if (codeLine == 0)
{
codeLine = lineNumber; codeMethod = methodName; codePath = filePath;
}
//lock (callbacksLock)
//{
lock (asyncLock)
@@ -165,8 +174,6 @@ public class AsyncReply
//if (Debug)
// Console.WriteLine($"AsyncReply: {Id} Then pending");
callbacks.Add(callback);
return this;

View File

@@ -39,8 +39,13 @@ namespace Esiur.Core;
public class AsyncReply<T> : AsyncReply
{
public AsyncReply<T> Then(Action<T> callback)
public AsyncReply<T> Then(Action<T> callback, [CallerMemberName] string methodName = null, [CallerFilePath] string filePath = null, [CallerLineNumber] int lineNumber = 0)
{
if (base.codeLine == 0)
{
base.codeLine = lineNumber; base.codeMethod = methodName; base.codePath = filePath;
}
base.Then((x) => callback((T)x));
return this;
}