2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-27 13:33:13 +00:00

Add project files.

This commit is contained in:
Ahmed Zamil
2017-09-15 23:40:03 +03:00
parent 4c95cb1cc6
commit 7ae722ab51
99 changed files with 14687 additions and 0 deletions

View File

@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Esiur.Engine
{
public class AsyncReply
{
protected List<Action<object>> callbacks = new List<Action<object>>();
protected object result;
object callbacksLock = new object();
//bool fired = false;
protected bool resultReady = false;
public bool Ready
{
get { return resultReady; }
}
public object Result
{
get { return result; }
}
public void Then(Action<object> callback)
{
callbacks.Add(callback);
if (resultReady)
callback(result);
// Trigger(this.result);
}
public void Trigger(object result)
{
//if (!fired)
//{
this.result = result;
resultReady = true;
lock (callbacksLock)
{
foreach (var cb in callbacks)
cb(result);
//callbacks.Clear();
}
/*
if (callback == null)
{
fireAtChance = true;
}
else
{
callback(result);
fired = true;
}
*/
//}
}
public AsyncReply()
{
}
public AsyncReply(object result)
{
resultReady = true;
this.result = result;
}
}
}