question

sravani kandarpa avatar image
sravani kandarpa asked Anirban Sen Chowdhary answered

.Net framework 4.5 await authorize hangs

I am running below code from my console application and it works perfectly and I can fetch data

static async Task GetCallLogs() {
 var rc = new RestClient(RINGCENTRAL_CLIENT_ID, RINGCENTRAL_CLIENT_SECRET, RINGCENTRAL_PRODUCTION_URL); await rc.Authorize("username", "ext", "password"); 
// making api calls
}


But when I am doing the same thing from the .NET framework controller, system hangs at await

public void  UpdateRingCentral()
   {
             var t= new GetCallLogs();
             t.Wait();
   }
public async Task GetCallLogs() { 
var rc = new RestClient(RINGCENTRAL_CLIENT_ID, RINGCENTRAL_CLIENT_SECRET, RINGCENTRAL_PRODUCTION_URL); await rc.Authorize("username", "ext", "password"); 
// making api calls
}


Any advice or suggestions for fixing this issue.

async c#
1 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

sravani kandarpa avatar image
sravani kandarpa answered
1 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Anirban Sen Chowdhary avatar image
Anirban Sen Chowdhary answered

This is a very common feature of .net platform which arise deadlock condition during making the actual REST call and parsing it as JSON .

There are many ways you can prevent this mentioned here .

Also refer here to get your answer

Another link you should read:

https://devblogs.microsoft.com/pfxteam/await-and-ui-and-deadlocks-oh-my/

1 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Anirban Sen Chowdhary avatar image
Anirban Sen Chowdhary answered

There is fee more docs available on these type of issue here.

1 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.