You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using ForceClient in an ASP.NET MVC project. I have a Salesforce service called by my controllers which makes use of ForceClient. I have implemented all of these methods asynchronously, however in MVC 5, child actions can't be marked async, so in a few cases I have had to create a synchronous version of these methods which uses .Result as follows (the async versions are identical to this except they use await instead of .Result):
string query = $"SELECT Id, Name, AccountId, Email, NOP_Customer_ID__c FROM Contact WHERE Id='{salesforceId}'";
try
{
var results = forceClient.QueryAsync<SalesforceContact>(query).Result;
return results.Records.FirstOrDefault();
}
catch (Exception ex)
{
throw new ApplicationException("Unable to retrieve contact.", ex);
}
This works fine on the version that's currently available on Nuget, but on the latest version, it results in a deadlock.
If it helps at all, I'm able to avoid the deadlock on the newest version by instead calling the async version of the method as follows (which is arguably cleaner anyway):
I'm running into this problem using v2.07.
As chippy opened the original request on Jan. 2017 - will there ever be a solution to this?
Does anybody have a simple enough workaround to use these calls in a syncronous way?
Don't know how chippy saved gabrieluy's live with the code example of how to trap the library to deadlock ;-)
I observed this issue as well, but was able to resolve it by adding .ConfigureAwait(false) to all the awaited async method calls inside the library that were missing it. I've added a pull request (#359) to resolve this issue. This resolved the issue for me.
I am using ForceClient in an ASP.NET MVC project. I have a Salesforce service called by my controllers which makes use of ForceClient. I have implemented all of these methods asynchronously, however in MVC 5, child actions can't be marked async, so in a few cases I have had to create a synchronous version of these methods which uses .Result as follows (the async versions are identical to this except they use await instead of .Result):
This works fine on the version that's currently available on Nuget, but on the latest version, it results in a deadlock.
If it helps at all, I'm able to avoid the deadlock on the newest version by instead calling the async version of the method as follows (which is arguably cleaner anyway):
The text was updated successfully, but these errors were encountered: