Refactored MtApiService: command will be executed in first expert will be invoked by quote tick

This commit is contained in:
DW
2016-04-13 16:41:32 +03:00
parent b803ed8567
commit 6f8a8728ed
7 changed files with 249 additions and 244 deletions
+37
View File
@@ -0,0 +1,37 @@
using System.Threading;
namespace MTApiService
{
public class MtCommandTask
{
private readonly EventWaitHandle _responseWaiter = new AutoResetEvent(false);
private MtResponse _result;
private readonly object _locker = new object();
public MtCommandTask(MtCommand command)
{
Command = command;
}
public MtCommand Command { get; private set; }
public MtResponse WaitResult(int time)
{
_responseWaiter.WaitOne(time);
lock (_locker)
{
return _result;
}
}
public void SetResult(MtResponse result)
{
lock (_locker)
{
_result = result;
}
_responseWaiter.Set();
}
}
}