So I have some code that I need to execute when an form activates its Shown event, and I need to await that code. I am doing this:
form.Shown += async (sender, args) => await BufferOpen(CurrentPath, CurrentEncoding, 1024 * 1024 * 5, statusProgressForm.progressBar1);
statusProgressForm.Show();
But the code still continues without awaiting the BufferOpen method. How can I do this with an anonymous function?
EDIT: Ok, so I think I screwed up the original post. Sorry about that. What I'm really trying to do is show a form and THEN on the shown event perform intensive code, as before when I just did this:
form.Show();
DoIntensiveTasks();
The GUI on the form would not properly load and the labels and such wouldn't display properly. I need to wait until the form is completely shown then do stuff.