wcf-ria-services

OpenRiaServices async methods


I'm still using OpenRiaServices and I update to version 5.0.0-preview0003.

I tried to add an async method :

[Invoke]
[RequiresAuthentication]
public async Task<string> GetTestAsync()
{
   return await Task.FromResult("TEST");
}

But when I'm calling it, the method never returns :

var test = DomainContext.GetTestAsync(CancellationToken.None).Result;

I see that there is no "await" in the generated code :

/// <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);
}

I tried to debug it but I don't know where the problem happens...

Any idea why ?


Solution

  • The issue has been answered over [at the OpenRiaServices Github)(https://github.com/OpenRIAServices/OpenRiaServices/issues/246)

    The issue was a deadlock due to calling Task.Result instead of awaiting the result