I have a problem where result ignores the wait timeout of 5000ms and returns it when .Result is done... This is causing my IIS to crash since none of the requests made to the IIS has a timeout and creates a very long queue and execution time.
EDIT: Clarification: It should return "123;NK" if the wait exceeds 5000ms.
public class Client : IMotorClient
{
private IMotorProxy Link { get; set; }
//private IOfficeGenerator OfficeGenerator { get; set; }
private IOfficeRegistryLegacy OfficeRegistry { get; set; }
public WebInternalGatewayClient(IMotorProxy proxy, IOfficeRegistryLegacy officeRegistry)
{
OfficeRegistry = officeRegistry;
Link = proxy;
}
public string Execute(string host, int port, string command)
{
var officeGuid = OfficeRegistry.GetOfficeGuid(host, port);
var result = "";
var task = Task.Run(() => result = Link.Submit(officeGuid, command).Result);
var value = task.Wait(TimeSpan.FromMilliseconds(5000));
if (!value)
{
result = "123;NK;";
}
return result;
}
}