I'm debugging something with the DownloadAsync method at the moment, and I'm causing one of the internal waits to throw by manipulating a remote client. This is "working" for the time being, but the exception that's thrown when a wait expires is extremely opaque; I'm not sure which of the several internal waits elapsed.
Here's the current signature of the void Wait:
Task Wait(WaitKey key, int? timeout = null, CancellationToken? cancellationToken = null);
This could be updated like so:
Task Wait(WaitKey key, string name = null, int? timeout = null, CancellationToken? cancellationToken = null);
The provided name could be stored inside of the PendingWait class, and then the Timeout implementation could be updated like:
public void Timeout(WaitKey key)
{
Disposition(key, wait =>
wait.TaskCompletionSource.TrySetException(new TimeoutException($"The wait{(string.IsNullOrEmpty(wait.Name) ? " " : $" for {wait.Name}")} timed out after {wait.Timeout} milliseconds")));
}
The only downside is the string allocation and storage in PendingWait, so some analysis will need to be done regarding the typical number of pending waits during different operations (potentially tens of thousands during a heavy search) and the Waiter class probably needs to be pulled out and have the heap inspected with growing numbers of instances.
I'm not sure I'll do it, the risk:reward ratio isn't the greatest.
I'm debugging something with the
DownloadAsyncmethod at the moment, and I'm causing one of the internal waits to throw by manipulating a remote client. This is "working" for the time being, but the exception that's thrown when a wait expires is extremely opaque; I'm not sure which of the several internal waits elapsed.Here's the current signature of the void
Wait:This could be updated like so:
The provided
namecould be stored inside of thePendingWaitclass, and then theTimeoutimplementation could be updated like:The only downside is the string allocation and storage in
PendingWait, so some analysis will need to be done regarding the typical number of pending waits during different operations (potentially tens of thousands during a heavy search) and theWaiterclass probably needs to be pulled out and have the heap inspected with growing numbers of instances.I'm not sure I'll do it, the risk:reward ratio isn't the greatest.