c# - Cache table with async method -


this extremely easy i'm starting async methods need help. want cache table list<> while winform loads save time. need execute simple task async :
list<item> itemslist = datacontext.items.where(x=>x.active == true).tolist<item>()
single task, no need cancellationtokensource

you need combination of tolistasync comments suggested , async onload event handler below. won't able await in constructor, , have mark events async void able await in them.

private list<item> itemslist = null;          public form1()         {             initializecomponent();             load += onload;         }          private async void onload(object sender, eventargs eventargs)         {             itemslist = await datacontext.items.where(x => x.active == true).tolistasync();         } 

Comments