public Listen ( System.TimeSpan maxWaitTime = null ) : void | ||
maxWaitTime | System.TimeSpan | |
return | void |
public void Listen(TimeSpan? maxWaitTime = null)
{
maxWaitTime = maxWaitTime ?? TimeSpan.FromSeconds(25);
var clock = new Stopwatch();
clock.Start();
while (State != NetworkState.CLOSING_ASSOCIATION && clock.Elapsed < maxWaitTime)
{
if (_abortRequested) { HandleAbort(); break; }
if (_cancelRequested) { HandleCancel(); }
IMessage message = Read();
if (message != null)
{
clock.Restart();
Process(message);
Stream.Flush();
clock.Restart();
}
}
}
public IEnumerable <CMoveResponse> GetResponse(CMoveRequest cMove, Entity ae) { var client = new TcpClient(); client.Connect(IPAddress.Parse(ae.IpAddress), ae.Port); var assoc = new Association(this, client) { AeTitle = ae.AeTitle }; PDataMessenger.Send(cMove, assoc); List <CMoveResponse> responses = new List <CMoveResponse>(); EvilDICOM.Network.Services.DIMSEService.DIMSEResponseHandler <CMoveResponse> action = null; action = (resp, asc) => { responses.Add(resp); if (resp.Status != (ushort)Status.PENDING) { this.DIMSEService.CMoveResponseReceived -= action; } }; this.DIMSEService.CMoveResponseReceived += action; assoc.Listen(); return(responses); }