设置连接超时时间
continuous-integration/drone/push Build is pending

This commit is contained in:
2024-08-09 13:46:08 +08:00
parent cebcf908f9
commit a1778d836b
@@ -145,9 +145,21 @@ namespace IRaCIS.Core.Application.Service
await client.AddRequestAsync(new DicomCEchoRequest());
await client.SendAsync();
// 创建一个超时任务,设置超时时间为1秒
var timeoutTask = Task.Delay(TimeSpan.FromSeconds(3));
// 发送 DICOM 请求
var sendTask = client.SendAsync();
// 等待任务完成,若超时任务先完成则抛出超时异常
if (await Task.WhenAny(sendTask, timeoutTask) == timeoutTask)
{
throw new TimeoutException("DICOM 请求超时。");
}
find.IsTestOK = true;
await _dicomAERepository.SaveChangesAsync();
return true;