I am trying to understand the async
and await
.Now i want to apply async
and await
keyword in my current project.My process structure are:
//DataAccess Private List<Users> GetAllUsers() { .... ; return List<Users> } //UI List<Users> UserList=new List<Users>(); private async void Ok_ClickAsync(object sender, RoutedEventArgs e) { //I want to select all user ant assign to UserList but currently it not use. UserList=await BindUser(); } private async Task<List<Users>> BindUser() { List<Users> model=await Task.Run(()=>GetAllUsers()); return model; } private void btnSave_Click(object sender, RoutedEventArgs e) { //I want to use UserList here and want to validate process }
Problem is if i click save click button quickly,UserList
count are 0
(Actually UserList
record are over 100,000).So I want to check BindUser()
process is finish or not before doing validation process in Save_Click()
. Please let me known for best solution and help me to understand async
and await
keyword. Thanks.