TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sandeep Gupta
NA
80
830
how to make async method wait till it get result and then proceed ?
Jan 1 2021 7:37 AM
await generic.getFindocFunds(users);
public async Task getFindocFunds(Users users)
{
try
{
Uri requestUri = new Uri("https://fintrader.myfindoc.com/api/v1/funds/view?client_id=" + users.mst_User.UserId.ToString() + "&type=all");
var objClint2 = new System.Net.Http.HttpClient();
objClint2.DefaultRequestHeaders.Add("Authorization", "Bearer " + users.mst_User.Token);
objClint2.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
System.Net.Http.HttpResponseMessage respon2 = await objClint2.GetAsync(requestUri);
string responJsonText2 = await respon2.Content.ReadAsStringAsync();
Dictionary<string, object> values1 = JsonConvert.DeserializeObject<Dictionary<string, object>>(responJsonText2);
if (values1["status"].ToString() == "success")
{
Dictionary<string, object> values21 = JsonConvert.DeserializeObject<Dictionary<string, object>>(values1["data"].ToString());
dynamic values22 = JsonConvert.DeserializeObject<dynamic>(values21["values"].ToString());
foreach (var item in values22)
{
if (item[0].ToString() == "Available")
{
users.cashAvailable = Convert.ToDouble(item[1]);
break;
}
}
}
}
catch (Exception ex)
{
Log.writeLog(ex, "getSamcoFunds()");
}
}
the main method does not wait for the called method result and proceed with further execution
Reply
Answers (
4
)
Which approach should i prefer?
asp.net fresher Machine test CRUD and Stored procedure program want