Results 1 to 2 of 2

Thread: Form KeyPreview on many forms of large application

  1. #1

    Thread Starter
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Form KeyPreview on many forms of large application

    Hello - just looking to get general opinions on this:
    As quick solution to the user wanting to be able to open a particular form from any other form (in a large application with many forms, not an MDI app), I added KeyPreview to each form and corresponding KeyPress event so that said form will open (ShowDialog) upon pressing F12 from all these other forms.

    Since this update has been in place, the user has been getting intermittent (maybe 2 or 3 within the course of a workday) but nasty errors such as "exception has been thrown by the target of an invocation" and the dreaded "out of memory".

    Is there reason to believe (off the top of your head) that the KeyPreview could be causing this?
    "It's cold gin time again ..."

    Check out my website here.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: Form KeyPreview on many forms of large application

    You obviously have a reason to suspect that it is so, but not anything you mentioned. I don't see any general reason why this would necessarily cause problems, but you may be getting into some strange looping. If all forms can transition to this other form (call it F12), how do you transition away from F12? It it just closes and sends the user back where they came from, that would be one thing, but if they can go from A to F12 to B to C to F12 (again) to A, and so forth, you may be creating a massive stack of information that is building up until it gets too large and overflows.

    You might be able to see this by looking at the stack trace after the program has been in operation for a bit. If the stack is tiny, all is well. If the stack is HUGE, then it may be that you are just piling calls ontop of calls without ever unwinding. However, that should really result in a Stack Overflow rather than the exceptions you are reporting.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width