I'm having some trouble getting the data from TaskCompleteSource. I am making an Async request to the server, and it should be returning the HTML from the login page. This works synchronous, but not Asyn.
When calling client.ExecuteAsync is it waiting for the response before it tries to get the data from the TaskCompleteSource? I'm very confused about what's going on here.
public Task<bool> login()
{
var tcs1 = new TaskCompletionSource<CsQuery.CQ>();
var tcs2 = new TaskCompletionSource<bool>();
RestSharp.RestRequest request;
CsQuery.CQ dom;
request = new RestSharp.RestRequest("/accounts/login/", RestSharp.Method.GET);
client.ExecuteAsync(request, (asyncResponse, handle) =>
{
tcs1.SetResult(asyncResponse.Content);
});
// Get the token needed to make the login request
dom = tcs1.Task.ToString();
// Other Code