Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

httpclient.GetAsync issue when using UWP #13

Open
ccarlo88 opened this issue Jun 20, 2020 · 1 comment
Open

httpclient.GetAsync issue when using UWP #13

ccarlo88 opened this issue Jun 20, 2020 · 1 comment

Comments

@ccarlo88
Copy link

ccarlo88 commented Jun 20, 2020

Hello!

First, congrats for the .NET API for Matrix! It worked really well with the Console example and is nice to have a SDK developed in .NET. I was making some testes with the sdk and when using UWP it hangs out here:

public MatrixRequestError Get (string apiPath, bool authenticate, out JToken result)
{
apiPath = GetPath (apiPath,authenticate);
Task task = client.GetAsync(apiPath); //Here more exactly
var res = RequestWrap(task);
res.Wait();
result = res.Result.result;
return res.Result.error;
}

The GetAsync function will never return.... and it will hang everything around after that. The reason is explained here:
https://stackoverflow.com/questions/10343632/httpclient-getasync-never-returns-when-using-await-async/10351400#10351400

I looked around the code and one (not nice) solution would be immediately after each Async httpclient task like GetAsync/PostAsync, to call task.Wait(). Of course if you make Async methods you could use the await keyword with the async methods when calling them.

I didn't implement it because I think you know better than I what to do in the SDK and you know Matrix/Synapse much much better than I. Keep on the good job and please don't let me alone in the .NET! 😄

@qwetboy10
Copy link

I had the same problem with WPF. You can get around this issue by creating a new thread, and doing all Matrix stuff on that thread, but that is a bit of a hack. I think the only real solution to this problem is just refactoring everything to async.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants