Skip to content

Commit 3821ca6

Browse files
committed
getPrinters: Increase timeout
1 parent 59887cc commit 3821ca6

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/ElectronNET.API/API/ApiBase.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,19 @@ protected void CallMethod3(object val1, object val2, object val3, [CallerMemberN
116116
}
117117

118118
protected Task<T> InvokeAsync<T>(object arg = null, [CallerMemberName] string callerName = null)
119+
{
120+
return this.InvokeAsyncWithTimeout<T>(InvocationTimeout, arg, callerName);
121+
}
122+
123+
protected Task<T> InvokeAsyncWithTimeout<T>(int invocationTimeout, object arg = null, [CallerMemberName] string callerName = null)
119124
{
120125
Debug.Assert(callerName != null, nameof(callerName) + " != null");
121126

122127
lock (this.objLock)
123128
{
124129
return this.invocators.GetOrAdd(callerName, _ =>
125130
{
126-
var getter = new Invocator<T>(this, callerName, InvocationTimeout, arg);
131+
var getter = new Invocator<T>(this, callerName, invocationTimeout, arg);
127132

128133
getter.Task<T>().ContinueWith(_ =>
129134
{
@@ -301,7 +306,7 @@ public Invocator(ApiBase apiBase, string callerName, int timeoutMs, object arg =
301306
_ = apiBase.Id >= 0 ? BridgeConnector.Socket.Emit(messageName, apiBase.Id) : BridgeConnector.Socket.Emit(messageName);
302307
}
303308

304-
System.Threading.Tasks.Task.Delay(InvocationTimeout).ContinueWith(_ =>
309+
System.Threading.Tasks.Task.Delay(timeoutMs).ContinueWith(_ =>
305310
{
306311
if (this.tcs != null)
307312
{

src/ElectronNET.API/API/WebContents.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public void OpenDevTools(OpenDevToolsOptions openDevToolsOptions)
139139
/// Get system printers.
140140
/// </summary>
141141
/// <returns>printers</returns>
142-
public Task<PrinterInfo[]> GetPrintersAsync() => this.InvokeAsync<PrinterInfo[]>();
142+
public Task<PrinterInfo[]> GetPrintersAsync() => this.InvokeAsyncWithTimeout<PrinterInfo[]>(5_000);
143143

144144
/// <summary>
145145
/// Prints window's web page.

0 commit comments

Comments
 (0)