Commit d38f9bb3 authored by Mahmoud Bakhtvar's avatar Mahmoud Bakhtvar

using new Task(async) to serialize Send

parent cc9cc376
...@@ -26,23 +26,20 @@ namespace C_UI ...@@ -26,23 +26,20 @@ namespace C_UI
var client = new DicomClient(inputsDto.ServerHost, inputsDto.Port, false, inputsDto.ServerAET, inputsDto.Aet); var client = new DicomClient(inputsDto.ServerHost, inputsDto.Port, false, inputsDto.ServerAET, inputsDto.Aet);
client.NegotiateAsyncOps(); client.NegotiateAsyncOps();
inputsDto.FileNames.ToObservable() inputsDto.FileNames.ToObservable()
.Select(async fileName => .Select(fileName => new Task(async () =>
{ {
var request = new DicomCStoreRequest(fileName); var request = new DicomCStoreRequest(fileName);
request.OnResponseReceived += (req, response) => logger.Info($"{response.Status}-{fileName}"); request.OnResponseReceived += (req, response) => logger.Info($"{response.Status}-{fileName}");
await client.AddRequestAsync(request); await client.AddRequestAsync(request);
await client.SendAsync(); await client.SendAsync();
}) }).ToObservable().Select(x => fileName))
.Select( .Concat()
t => t.Exception.Flatten()
)
.Subscribe( .Subscribe(
filename => filename =>
logger.Warn($"file sent:{filename}"), logger.Warn($"file sent:{filename}"),
onError => onError =>
logger.Error(onError.Message ), logger.Error(onError.Message),
() => { } () => { });
);
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment