Link to home
Start Free TrialLog in
Avatar of emub
emubFlag for United Kingdom of Great Britain and Northern Ireland

asked on

First time my app hits an exception there is a long pause before it resumes

Hi,

Im trapping an error with the usall

Try
      '//Code
Catch EX As Exception
      '// Code
End Try

but when running my app, the first time I get an exception there is a long pause at the "Catch EX As Exception" before it resume's then after that the Exception is caught really fast an the appication flows smoothly?

?? Any Ideas ??

The delay still occurs even if I specify the error type with

Catch ex As System.ObjectDisposedException
Avatar of RonaldBiemans
RonaldBiemans

I think that has to do with the JIT (Just In Time)  compiler, the first time it is used it hasn't been cached yet.

Regarding your problem, I know this is related to the solution I gave in a previous thread.
Just a thought you don't have to use a collection, if you set owner property each "child" window to me
you can use the me.ownedforms to check which are active

so when you create

      Dim oNewForm As New frmDisplayRecord(iRecordToOpen)
      oNewForm.StartPosition = FormStartPosition.CenterScreen
      oNewForm.TopMost = True
      oNewForm.Owner = Me  <---  ADD this line
      oNewForm.Focus()
      frmMain.oFormCollection.Add(oNewForm)

you can use

        Dim oForm2 As Form
        For Each oForm2 In Me.OwnedForms
              oform2.activate
              .. or oform2.whatever
        Next


if you do it this way you won't have to catch the error
Avatar of emub

ASKER

Hi, Sorry you Lost me a little there,  I remembe I as testing the relivant for to see if it was still active before I tied to bring it to focus?
Avatar of emub

ASKER

You saing I remove the whole collections thing? And just use the .OwnedForms array to keep track of all the forms I have open?  If so I presume once a use closes a form its automatically removed from the Parent.OwnedForms array?
ASKER CERTIFIED SOLUTION
Avatar of RonaldBiemans
RonaldBiemans

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of emub

ASKER

Yea there worked great, the actual amount of coding for the Form management was much less that my orginal idea.

thx