GetAll() Problem
Hello,
I have a problem getting started with this Nuget.
the problem is with the await operator. This is a clear and new project just to make some tests.
please take a look at the attached picture. Any help will be greatly appreciated
WooCommerce.NET version 082

try var products = wc.Product.GetAll().Result;
Thank you for your prompt reply. I still get the same message
On Thu, Mar 11, 2021 at 10:16 AM James Yang [email protected] wrote:
try var products = wc.Product.GetAll().Result;
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/XiaoFaye/WooCommerce.NET/issues/577#issuecomment-796555009, or unsubscribe https://github.com/notifications/unsubscribe-auth/AS7LT5D6OGYDOY3SWP6SZADTDB35ZANCNFSM4Y7ZFZDA .
Actually now I get a runtime error

Never mind that. Everything works ok. thanks for your great help
For the record, afaik, to use await, the function signature needs to be: public async Task<T> SomeAsyncFuction()
AFAIK a WPF event handler should be async void and then you could await within this event handler.
(about the only place where you should use async void instead of async Task)
So an alternative solution:
private async void button1_Click(object sender, EventArgs e)
{
var products = await wc.Products.GetAll();
/* ... */
}
OP, please be careful with stuff such as Result, Wait, etc, because they can bite you if you don't know their idiosyncrasies, see for example https://blog.stephencleary.com/2012/07/dont-block-on-async-code.html
You'll probably want to read up on asynchronous programming as well. https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/async/