【发布时间】:2025-11-24 10:05:02
【问题描述】:
我仍在使用 OpenRiaServices,并更新到版本 5.0.0-preview0003。
我尝试添加一个异步方法:
[Invoke]
[RequiresAuthentication]
public async Task<string> GetTestAsync()
{
return await Task.FromResult("TEST");
}
但是当我调用它时,该方法永远不会返回:
var test = DomainContext.GetTestAsync(CancellationToken.None).Result;
我看到生成的代码中没有“等待”:
/// <summary>
/// Asynchronously invokes the 'GetTest' method of the DomainService.
/// </summary>
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
/// <returns>An operation instance that can be used to manage the asynchronous request.</returns>
[DebuggerStepThrough()]
public System.Threading.Tasks.Task<InvokeResult<string>> GetTestAsync(CancellationToken cancellationToken = default(CancellationToken))
{
this.ValidateMethod("GetTest", null);
return this.InvokeOperationAsync<string>("GetTest", null, true, cancellationToken);
}
我试图调试它,但我不知道问题出在哪里......
知道为什么吗?
【问题讨论】:
-
关于在WCF中实现异步服务操作的信息,可以参考这个链接:docs.microsoft.com/en-us/dotnet/framework/wcf/…
标签: wcf-ria-services