I'm having problems with some of my code specifically this part. I'm calling an async
method that returns a Task<List<>>
(cant return a regular list because the method is async). But, I'm not able to convert it to a regular list, which is what I need. Is that even possible? If so, is anyone able to help out? :)
static void Main(string[] args) {
Program p = new Program();
List<Product> products = p.getProducts();
}
public async Task<List<Product>> getProducts() {
// calling woocommerce api
MyRestApi rest = new MyRestApi("http://someurl.com/wp-json/wc/v2", "consumer key", "consumer secret");
WCObject wc = new WCObject(rest);
List<Product> products = await wc.Product.GetAll();
return await Task.Run(() => new List<Product>(products));
}
>` that was returned by `wc.Product.GetAll()`. Probably the best help is a way to async-await in the code that is currently the main method. https://stackoverflow.com/questions/9208921/cant-specify-the-async-modifier-on-the-main-method-of-a-console-app