Reputation: 34198
hello guys i built wcf service i have two methods insert and get(which must return list) inserts method works correctly
This is get method:
public List<string> GetUsersList()
{
csmasterDataContext db = new csmasterDataContext();
List<string> _uList = new List<string>();
_uList = (from d in db.users select d.username).ToList();
return _uList;
}
when i call this method like this :
List<string> _UserList = new List<string>();
_UserList = webService.GetUsersListAsync();
visual studio gives error:
Cannot implicitly convert type 'void' to 'System.Collections.Generic.List<string>'
Does anyone have a idea what is my problem?
Upvotes: 0
Views: 782
Reputation: 5123
Async call of web service is asynchronous it does not return a value... you have to call it like this
webService.GetUsersListAsyncCompleted +=
new EventHandler<GetUsersListEventArgs> (GetUsersListCompleted);
webService.GetUsersListAsync();
void GetUsersListCompleted(object sender, GetUsersListEventArgs e)
{
// Set your return here
usersList = e.Result;
}
Upvotes: 4