Challenge in cross threading during application restoration

Topics: CAB & Smart Client Software Factory
Feb 22, 2007 at 2:17 PM
Edited Feb 22, 2007 at 2:17 PM
I'm developing a CAB application which saves and restores the presentation state of the application while the users closes shell (Main form) and reopen the applicationl. So, suppose the user has opened three Mdi children from the shell and then closes the shell. Next time, when the application is started, i need to load all the three Mdi Children asynchronously (rather synchronously) to avoid performance issue. In this application, Mdi children are loaded through CAB in MdiWorkspace.
Running the process of "Loading of Mdi Children" in separate thread shows a cross-threading error, as the CAB tries to access the Shell running on the main thread for dynamic loading of smartpart.

Thanks in Advance,
Feb 27, 2007 at 1:58 PM
It is my understanding that UI code is not thread safe, and that every call to the shell involving UI actions should check for the InvokeRequired boolean and call through Invoke accordingly . Above all there is some common state shared between workitems that are not guaranteed to be thread safe and would need some locking mechanism to be in place for it to work properly. Bottom line, at least the code that access the UI from a different thread will need to be modified to ensure thread safety, and later you will need to check the communication between workitems.

Let me know if this helps,

Federico Delgado