I'm learning about async/await, and ran into a situation where I need to call an async method
that should return an object or list of same object.
Is this the right way to implement ?
from AManager.cs
public async Task Initialize(string objectPath)
{
AnObject someObject = await BClass.GetAnObject(objectPath);
}
and this is the called method
Class B:
public async Task<AnObject> GetAnObject(string objectPath)
{
AnObject someObj = new AnObject();
return someObj;
}
What happens if I want to return a list of object ? I should create a wrapper that contains a list ? and return that wrapper ?
Because this is not applicable:
public async Task<List<AnObject>> GetAnObject(string objectPath)
> GetAnObject(string objectPath)" is perfectly valid. You just have to return a list of objects instead...
– bigge Mar 12 '13 at 07:48