i’d like to create loading screen during executing funcion – something like loading screen in games, new window or some graphics.
So I press button “Start” – app starts doing some stuff, and childform window shows with graphic -“Function in progress, please wait”
How to do it?
You can use a BackgroundWorker in order to execute your functionality in a separate thread. BackgroundWorker has a lot of feature to support for the functionality that you are looking for. If you didn’t use another thread to execute your function, the main thread (UI thread) will be busy and child window won’t work properly.
Some key notes on backgroundWorker. DoWork in a different thread, report progress to the main thread and cancel the asynchronous process are the most important functionalities in BackgroundWorker. Below example demonstrates those three functionalities quite clearly. But it displays the actual percentage of the task completion. If you just want to show a message and ProgressBar with Marquee style, you don’t have to switch on the
WorkerReportsProgressflag and no needProgressChangedevent implementation.There are heaps of examples available on the web.
Reference