@@ -31,7 +31,7 @@ protected enum SocketEventNameTypes
3131 CamelCase ,
3232 }
3333
34- private const int InvocationTimeout = 1000 ;
34+ private static readonly TimeSpan InvocationTimeout = 1000 . ms ( ) ;
3535
3636 private readonly string objectName ;
3737 private readonly ConcurrentDictionary < string , Invocator > invocators ;
@@ -120,7 +120,7 @@ protected Task<T> InvokeAsync<T>(object arg = null, [CallerMemberName] string ca
120120 return this . InvokeAsyncWithTimeout < T > ( InvocationTimeout , arg , callerName ) ;
121121 }
122122
123- protected Task < T > InvokeAsyncWithTimeout < T > ( int invocationTimeout , object arg = null , [ CallerMemberName ] string callerName = null )
123+ protected Task < T > InvokeAsyncWithTimeout < T > ( TimeSpan invocationTimeout , object arg = null , [ CallerMemberName ] string callerName = null )
124124 {
125125 Debug . Assert ( callerName != null , nameof ( callerName ) + " != null" ) ;
126126
@@ -245,7 +245,7 @@ internal class Invocator<T> : Invocator
245245 private readonly Task < T > tcsTask ;
246246 private TaskCompletionSource < T > tcs ;
247247
248- public Invocator ( ApiBase apiBase , string callerName , int timeoutMs , object arg = null )
248+ public Invocator ( ApiBase apiBase , string callerName , TimeSpan timeout , object arg = null )
249249 {
250250 this . tcs = new TaskCompletionSource < T > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
251251 this . tcsTask = this . tcs . Task ;
@@ -306,15 +306,15 @@ public Invocator(ApiBase apiBase, string callerName, int timeoutMs, object arg =
306306 _ = apiBase . Id >= 0 ? BridgeConnector . Socket . Emit ( messageName , apiBase . Id ) : BridgeConnector . Socket . Emit ( messageName ) ;
307307 }
308308
309- System . Threading . Tasks . Task . Delay ( timeoutMs ) . ContinueWith ( _ =>
309+ System . Threading . Tasks . Task . Delay ( timeout ) . ContinueWith ( _ =>
310310 {
311311 if ( this . tcs != null )
312312 {
313313 lock ( this )
314314 {
315315 if ( this . tcs != null )
316316 {
317- var ex = new TimeoutException ( $ "No response after { timeoutMs : D} ms trying to retrieve value { apiBase . objectName } .{ callerName } ()") ;
317+ var ex = new TimeoutException ( $ "No response after { timeout : D} ms trying to retrieve value { apiBase . objectName } .{ callerName } ()") ;
318318 this . tcs . TrySetException ( ex ) ;
319319 this . tcs = null ;
320320 }
0 commit comments