mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-02 21:47:47 +00:00
Refactored MtApiService: command will be executed in first expert will be invoked by quote tick
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user