mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-06-27 05:23:13 +00:00
updates
This commit is contained in:
@ -56,6 +56,10 @@ namespace Esyur.Core
|
||||
return (object[])base.Wait();
|
||||
}
|
||||
|
||||
public new object[] Wait(int timeout)
|
||||
{
|
||||
return (object[])base.Wait(timeout);
|
||||
}
|
||||
|
||||
public void Seal()
|
||||
{
|
||||
|
@ -28,13 +28,18 @@ using System.Text;
|
||||
|
||||
namespace Esyur.Core
|
||||
{
|
||||
public class AsyncException: Exception
|
||||
public class AsyncException : Exception
|
||||
{
|
||||
|
||||
|
||||
public readonly ErrorType Type;
|
||||
public readonly ExceptionCode Code;
|
||||
|
||||
public AsyncException(Exception exception) :base(exception.Message, exception)
|
||||
{
|
||||
Type = ErrorType.Exception;
|
||||
Code = 0;
|
||||
}
|
||||
|
||||
public override string StackTrace => InnerException != null && Type == ErrorType.Exception ? InnerException.StackTrace : base.StackTrace;
|
||||
|
||||
public AsyncException(ErrorType type, ushort code, string message)
|
||||
: base(type == ErrorType.Management ? ((ExceptionCode)code).ToString() : message)
|
||||
|
@ -89,6 +89,27 @@ namespace Esyur.Core
|
||||
}
|
||||
|
||||
|
||||
public object Wait(int millisecondsTimeout)
|
||||
{
|
||||
if (resultReady)
|
||||
return result;
|
||||
|
||||
if (Debug)
|
||||
Console.WriteLine($"AsyncReply: {Id} Wait");
|
||||
|
||||
if (!mutex.WaitOne(millisecondsTimeout))
|
||||
{
|
||||
var e = new Exception("AsyncReply timeout");
|
||||
TriggerError(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (Debug)
|
||||
Console.WriteLine($"AsyncReply: {Id} Wait ended");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public object Result
|
||||
{
|
||||
get { return result; }
|
||||
@ -210,9 +231,9 @@ namespace Esyur.Core
|
||||
if (exception is AsyncException)
|
||||
this.exception = exception as AsyncException;
|
||||
else
|
||||
this.exception = new AsyncException(ErrorType.Management, 0, exception.Message);
|
||||
|
||||
this.exception = new AsyncException(exception);
|
||||
|
||||
|
||||
// lock (callbacksLock)
|
||||
// {
|
||||
foreach (var cb in errorCallbacks)
|
||||
|
@ -79,6 +79,12 @@ namespace Esyur.Core
|
||||
{
|
||||
return (T)base.Wait();
|
||||
}
|
||||
|
||||
public new T Wait(int millisecondsTimeout)
|
||||
{
|
||||
return (T)base.Wait(millisecondsTimeout);
|
||||
}
|
||||
|
||||
/*
|
||||
protected new List<Action> callbacks = new List<Action>();
|
||||
protected new object result;
|
||||
|
Reference in New Issue
Block a user