Skip to content

Commit

Permalink
同步调用Invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Jun 24, 2024
1 parent 9279e6b commit 1dcc815
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion NewLife.Remoting/Clients/ClientBase.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Concurrent;
using System.Diagnostics;
using System.IO;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Net.NetworkInformation;
using System.Reflection;
Expand All @@ -13,6 +13,9 @@
using NewLife.Security;
using NewLife.Serialization;
using NewLife.Threading;
#if !NET40
using TaskEx = System.Threading.Tasks.Task;
#endif

namespace NewLife.Remoting.Clients;

Expand Down Expand Up @@ -221,6 +224,14 @@ public virtual async Task<TResult> OnInvokeAsync<TResult>(String action, Object?
}
}

/// <summary>同步调用</summary>
/// <typeparam name="TResult"></typeparam>
/// <param name="action"></param>
/// <param name="args"></param>
/// <returns></returns>
[return: MaybeNull]
public virtual TResult Invoke<TResult>(String action, Object? args = null) => TaskEx.Run(() => InvokeAsync<TResult>(action, args)).Result;

/// <summary>设置令牌。派生类可重定义逻辑</summary>
/// <param name="token"></param>
protected virtual void SetToken(String? token)
Expand Down

0 comments on commit 1dcc815

Please sign in to comment.