Hi all,
I am working on an CFv2 app that needs to run a few processes before displaying the main form of the app. I want to have a loading screen with a progress bar and label that are updated to reflect where we are in the process of initializing the app. The loading screen is the first one the user sees, but FormMain is loading first and opens the loading screen in a separate thread while the main form continues processing.
I currently have the app loading the loading screen while the rest of the app initializes and then it unloads and displays my main form as it should. I based my code off of a webcast by Maarten Struys (Creating a Windows Mobile Line of Business Application - episode 6 of 13, User Interface) and it is working fine. The thing I need some help with is updating the UI of the loading screen, which is running in it's own thread.
Here is the flow of the app so far:
1) App starts, and I throw up a loading screen in it's own thread (now off of the main UI thread of main form)
2) App continues to run it's initialization processes in the background, both on the main UI thread (NOT the loading screen thread) and a couple of worker threads spawned by the main thread
3) App initialization finishes, the loading screen and thread are terminated and the main form is displayed
What is the best way to update a label on the loading screen, that is in it's own worker thread Really, the loading screen doesn't do anything except display status/progress messages and let the user know the app is loading, but it is running on a worker thread other than the main UI thread. I have looked at a few examples but am a little confused, as they all seem to discuss updating a UI control on the main UI thread that created the worker thread. One option I read is that I should create a new EventArgs class that inherits from EventArgs, and then have the splash screen subscribe to that event and have the main form and worker threads trigger that event, but I am a little lost as to how to do that.
Any suggestions
Thanks in advance!

Update Control on Loading/Splash Screen in Separate Thread
Greg J. Brown
So, would the preferred way of doing the splash screen be to put it on the main UI thread as you suggest, and keep the other controls on the form invisible until the app finishes initializing, then hide the splash controls and show the other controls (a datagrid, etc.)
Thanks for your help,
LJ
cyberjoe2
Hi
Please tell me how created splash form in access
Tank you
jwraith
Sure, you can do that. Or, create a separate splash screen form and pop it up on top of the main form. Hide it as soon as you done.
Liu Feng
Few rules with UI:
1. You can only create/access forms on a main UI thread (the thread message pump is running) on, it will not work any other way.
2. You can not do anything with the form from any thread but main UI thread. To access controls from another thread Control.Invoke() must be used (which marshals that access to UI thread).
That means your #1 is not possible the way you envision it. However, it is possible to show splash screen on UI thread, then start number of worker threads which would update controls on forms using Control.Invoke(). You have to keep main UI thread unblocked or it won’t work.
If you don’t know how to use Control.Invoke(), please look it up on MSDN or search this forum.
magcianaux