Ok so I have a WPF application which on button press runs through a list of tests like this:
- RunTest button pressed in GUI
- BackgroundWorker is created and starts running DoWork (see below):
When t.Name == "TestSpecial" I want to show an image in the UI before I proceed. It's crucial that the image is showing before I continue.
DoWork(...) { List<Test> tests = .... for (Test t in tests) { switch(t.Name) { case "Test1": //Do something break; case "Test2": //Do something else break; ... case "TestSpecial": // Here I want to: // 1. Tell UI to show an image on the screen // 2. Wait for the image to show up // 3. Continue with my test break; case "TestN+1": //Do something completly different break; } } }
I could probably use the Dispatcher.InvokeAsync
or similar to get the image to show but is there any way to wait for it to finish or in some other way garantuee that the image is showing before proceeding?