• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 781
  • Last Modified:

VB6 Debug "END" button vs. App termination

I am using VB6 as my test environment for an ATL COM activeX object in a dll.  The COM activeX object accesses the data in the VB6 test app.  When I run the test app as an .exe it works fine.  But when I run the app from the VB6 IDE in debug mode and terminate it with the debug "END" button in the toolbar, VB6 terminates without any warning or error.  And terminating debug from within the app still works.  I need to know exactly what each of these two debug termination methods do behind the scenes and what the differences are between them.  A sequence of events upon pressing the END button would be nice, a step-by-step description of what happens.  Do you know this or know where I can find a description of this sort?  Thanks.
0
tkamrath
Asked:
tkamrath
  • 3
  • 3
  • 3
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
END when using unsafe subclassing can have that effect....
0
 
tkamrathAuthor Commented:
No subclassing being done.  Do you know what the END button does and what the diff is between it and ending the app from within (i.e. close button on the app main form)?
0
 
PaulHewsCommented:
Pressing the End button is similar to calling the End statement.  Both bring your execution to an immediate halt, and don't allow your process to clean up after itself.  

For normal termination, you finish processing, unload forms, close connections and release resources.  If you start from Sub Main, then when that sub finishes executing, your program stops.  If you start from a form, then when all forms are unloaded, your program will stop.  

When you hit the end button, or use the End statement, then the environment attempts as clean an exit as possible, without continuing to run your code.  Resources opened with API methods are least likely to be cleaned up, so depending on your usage, you may leave open files, unreleased GDC resources etc and other Very Bad Things.

What's causing your IDE to crash, I can't really speculate on, except to say that I've occasionally seen things like this.  You might check the event log to see if anything is being recorded there.


0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
END kills the process directly, in an unclean why.
the close button will request the Form_QueryUnload event, and if the cancel parameter is not set the true, it will call the Form_Unload event, and finally release all the resources.
0
 
tkamrathAuthor Commented:
My ActiveX object creates a thread.  And I have a mechanism to terminate the thread before the app is closed.  But this does not help in the case of an END.  So there is no mechanism to force a cleanup when VB ends a debug session?  A way to force a form deactivate or unload or something?
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
do not use END as such.
if you have a method to close the thread(s), use that before using END.
0
 
PaulHewsCommented:
>So there is no mechanism to force a cleanup when VB ends a debug session?

Other than by normally terminating your program by the methods suggested above, no there really isn't any way to do that when clicking the "End" button.
0
 
tkamrathAuthor Commented:
So this problem exists for anyone who does multi-threading in VB6?  I don't see how you can get around it.  If the application gets started and has generated other threads there is no way of closing them cleanly when a debug session is closed, right?  This may not be a problem for threads that do not share any data, but if the threads access any part of the main thread then this will happen. BUMMER!
0
 
PaulHewsCommented:
>So this problem exists for anyone who does multi-threading in VB6?

If it was an active X EXE developed in VB6, then you could run an instance of the IDE for the ActiveX component and control the debugging there.  

In your case the multithreading is external to the VB IDE, so you will need to shutdown gracefully and carefully to prevent a crash and burn effect.

And multithreading in VB is hard enough anyway, that one writer compared it to juggling flaming knives while blindfolded.  There is no real support for debugging multithreaded applications in VB6.  




0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now