设置连接超时时间
continuous-integration/drone/push Build is pending
Details
continuous-integration/drone/push Build is pending
Details
parent
cebcf908f9
commit
a1778d836b
|
@ -145,9 +145,21 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
await client.AddRequestAsync(new DicomCEchoRequest());
|
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;
|
find.IsTestOK = true;
|
||||||
|
|
||||||
await _dicomAERepository.SaveChangesAsync();
|
await _dicomAERepository.SaveChangesAsync();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue