Hi José
It would seem that the problem is something to do with creating controls
whilst the user uses other applications. The problem was this
1) My app starts importing data
2) The app updates the UI every 500 milliseconds
3) Each time the UI is updated I do this
3A) Remove the only control from my form + dispose it
3B) Get a factory to create a control for the "current object" I want to
display
3C) Add that control to my form
(I only have 1 form in my app, but lots of user controls)
4) Loop #3
Now the user goes and opens the program manager and starts moving between
folders, or maybe the user keeps checking the memory and/or battery levels,
and this is what causes the problem.
My app can run happily if the user doesn't touch any other apps. It can
also run to completion if I open every app on the PPC I can find and then
run it. If however the user is "using" the apps then the following fails:
at Microsoft.AGL.Common.MISC.HandleAr()
at System.Windows.Forms.Control._InitInstance()
at System.Windows.Forms.Control..ctor()
It seems that merely selecting / unselecting folders in the program manager
repeatedly triggers this bug. Then even if trap OOM exceptions + add a
Thread.Sleep + try again it makes no difference even if I close all other
running apps. Once the control creation has failed once the app is doomed
to fail at creating any controls at all from that point onwards.
My solution was pretty crappy, but it seems to work. The event that
triggers the UI change no longer does that, instead it does this
1) Event triggered
2) GuiTimer.Enabled = true (interval is 100ms)
3) GuiTimer_Tick updates the GUI
It seems that updating the GUI from a timer rather than directly from my
code does the trick (fingers crossed).
Pete