My windows form has a few controls that is causing 2-3 seconds of delay after its first Form.Show()
function call and before code execution Load()
function is fired. All other Form.Hide()
and Form.Show()
functions after the first Form.Show()
do not take time.
Can I initialize the form and its controls beforehand without showing it on the user so that it loads quickly on the first Form.Show()
function call? I would like to initialize the form and its controls on a splash screen and then execute Form.Show()
function.
I also tried Form.Hide()
immediately after Form.Show()
during splash screen to avoid delay in form loading afterwards on actual first Form.Show()
called on user click but it shows the form for a few milliseconds on the user screen after Form.Show()
call and before the Form.Hide()
call which gives wrong impression.
So, I chose not to display page on user screen even for a few milliseconds to load/initialize it and its control before its first actual Form.Show()
call by user.
Note: I am not exactly able to determine what is causing the delay. I put a break-point on Form.Show() function call called by a user click and on the first instruction of Form_Load() function of the form. And when I run the code, the code execution goes from Form.Show() to directly Form_Load() function of the form and this is where the delay is happening. Because the delay happens between the Form.Show() instruction call by user click to show the form, and when the code goes into Form_Load function as seen by the code execution using breakpoints.