|
-
Apr 19th, 2005, 01:39 PM
#1
Thread Starter
Need-a-life Member
Program not ending
The EXE I'm running does not finish (the process is still active) in the Task Manager's list. Even after I unload all the forms and "END".
Is there anyway to detect which object avoids it from unloading??
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Apr 19th, 2005, 01:51 PM
#2
Re: Program not ending
Mc Brain,
Detect the objects, no. You will have to go throught your code and make sure that when you load the object that you set it to Nothing when you are done with it.
-
Apr 19th, 2005, 01:59 PM
#3
Hyperactive Member
Re: Program not ending
Use this to exit your application:
VB Code:
For Each Form in Forms
unload Form
set form = nothing
Next Form
-
Apr 19th, 2005, 02:12 PM
#4
Re: Program not ending
Here is my routine that exits a program properly, after closing all forms and releasing all objects.
VB Code:
Private Sub ExitProgram_Click()
Dim frm As Form
Dim obj As Object
If InventoryDeducted = False Then Call CloseInv ' If Necessary !
For Each frm In Forms
If frm.Name <> Me.Name Then ' Unload this form LAST
For Each obj In frm
On Error Resume Next
Unload obj
Set obj = Nothing
Next
Unload frm
Set frm = Nothing
End If
Next
On Error Resume Next
For Each obj In frm
Unload obj
Set obj = Nothing
Next
Set frm = Nothing
Unload Me
End Sub
Last edited by dglienna; Apr 19th, 2005 at 02:27 PM.
-
Apr 19th, 2005, 02:21 PM
#5
Thread Starter
Need-a-life Member
Re: Program not ending
I'm already using a similar code... but it does not end.
VB Code:
Dim frm As Form
Set Juego = Nothing
Set MessagesToServer = Nothing
Set Canto = Nothing
Set Dichos = Nothing
' Set Quejas = Nothing
Set fTablero = Nothing
Set StBy = Nothing
Set ImgLst = Nothing
Set tFallo = Nothing
Set OtroJuego = Nothing
For Each frm In Forms
If frm.Name <> Me.Name Then
Unload frm
Set frm = Nothing
End If
Next
If udpPeer.State Then udpPeer.Close
End 'Just In Case
What's more astonish... is that it refuses to END (see the last line of code).
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Apr 19th, 2005, 02:29 PM
#6
Frenzied Member
Re: Program not ending
 Originally Posted by Mc Brain
The EXE I'm running does not finish (the process is still active) in the Task Manager's list. Even after I unload all the forms and "END".
Is there anyway to detect which object avoids it from unloading??
I encountered this problem a week ago.... the problem was my Unload event code... it was accessing a form's property which resulted in the loading of that form again... I also tried using End but that didn't work as eventually the conditions which lead to End statement were becoming false in Load Event of form...
-
Apr 19th, 2005, 02:29 PM
#7
Re: Program not ending
You don't unload Me. Try using my code to see if it makes any difference.
Are you stepping thru the code to make sure that it runs?
Last edited by dglienna; Apr 19th, 2005 at 02:53 PM.
-
Apr 19th, 2005, 02:33 PM
#8
Thread Starter
Need-a-life Member
Re: Program not ending
 Originally Posted by dglienna
You don't unload Me. Try using my code to see if it makes any difference.
Are you stepping thru the code to make sure that it runs?
A plain old END would prolly do it, though.
I cannot step through the code... on the IDE it ends smoothly.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Apr 19th, 2005, 02:43 PM
#9
Re: Program not ending
Mc Brain,
Search your code for any clauses like:
Set <object> = <object>
and make sure that these object are set to Nothing.
-
Apr 19th, 2005, 03:06 PM
#10
Thread Starter
Need-a-life Member
Re: Program not ending
 Originally Posted by moinkhan
I encountered this problem a week ago.... the problem was my Unload event code... it was accessing a form's property which resulted in the loading of that form again... I also tried using End but that didn't work as eventually the conditions which lead to End statement were becoming false in Load Event of form...
After the Finalizar subroutine (which code is the one I posted before)... it executes nothing!! Here's the mkcDebugger's log.
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: frmTablero SetIcon
*Tute v1.0.0*: Globals GetSetting
*Tute v1.0.0*: Registry GetSettingString
*Tute v1.0.0*: frmTablero Form_Resize
*Tute v1.0.0*: frmTablero Form_Activate
*Tute v1.0.0*: Globals GetSetting
*Tute v1.0.0*: Registry GetSettingString
*Tute v1.0.0*: frmTablero TB_ButtonClick
*Tute v1.0.0*: frmTablero submnu_Salir_Click
*Tute v1.0.0*: frmTablero EnRed
*Tute v1.0.0*: frmTablero Form_QueryUnload
*Tute v1.0.0*: frmTablero Form_Unload
*Tute v1.0.0*: frmTablero Finalizar
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Apr 19th, 2005, 03:17 PM
#11
Thread Starter
Need-a-life Member
-
Apr 29th, 2005, 05:27 AM
#12
Thread Starter
Need-a-life Member
-
Apr 29th, 2005, 05:32 AM
#13
Re: Program not ending
Is your exe listed on the Applications or in the Processes? Sometimes I also encounter the same problem with VB6, its not listed in the applications but is listed in the processes and CPU usage really rises.....
-
Apr 29th, 2005, 05:33 AM
#14
Re: Program not ending
it sounds as if you maybe calling the unload from a loop, which continues after unloading all. immediately after calling unload me, try exit sub
pete
-
Apr 29th, 2005, 05:37 AM
#15
Re: Program not ending
What does this line do?
VB Code:
If udpPeer.State Then udpPeer.Close
Is it a winsock? Maybe that line is the beast?
-
Apr 29th, 2005, 06:14 AM
#16
Thread Starter
Need-a-life Member
Re: Program not ending
 Originally Posted by dee-u
Is your exe listed on the Applications or in the Processes? Sometimes I also encounter the same problem with VB6, its not listed in the applications but is listed in the processes and CPU usage really rises.....
It's on both lists.
 Originally Posted by westconn1
it sounds as if you maybe calling the unload from a loop, which continues after unloading all. immediately after calling unload me, try exit sub
pete
Why would it work at my home's computer?
 Originally Posted by dee-u
What does this line do?
VB Code:
If udpPeer.State Then udpPeer.Close
Is it a winsock? Maybe that line is the beast?
It's a winsock. If it has an open port (UDP) it closes it. It's not connected with any machine, it's not TCP it is just listening to a port... just in case any other instance of the game "talks" to it.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Apr 29th, 2005, 06:23 AM
#17
Re: Program not ending
 Originally Posted by Mc Brain
After the Finalizar subroutine (which code is the one I posted before)... it executes nothing!!
The Finalizer event? That event is only fired when there is no references left to your class or form. Try moving it to the Unload event instead.
On a side note... I see this code all the time (several time in this thread):
VB Code:
Dim frm As Form
For Each frm In Forms
Unload frm
Set frm = Nothing
Next
Now what does the line that sets frm to Nothing do? It destroys the frm reference which will be destroyed anyway when the Next statement runs since it then references another form. Let's say I have a Form called Form2 and I use this code:
VB Code:
Dim frm As Form
Form2.Load '<-- creates the Form and uses the Form2 reference
Set frm = Form2 '<--- Let frm reference Form2
In the above code I have two references to the same object. Setting frm to Nothing will destroy one of them not the origional one.
-
Apr 29th, 2005, 06:39 AM
#18
Thread Starter
Need-a-life Member
Re: Program not ending
 Originally Posted by Joacim Andersson
The Finalizer event? That event is only fired when there is no references left to your class or form. Try moving it to the Unload event instead.
Ok, my mistake. I should not have called it "event". It's not actually an event but a subroutine. The Finalizar subroutine gets called whenever I say so (which is in the Form_Unload).
 Originally Posted by Joacim Andersson
On a side note... I see this code all the time (several time in this thread):
VB Code:
Dim frm As Form
For Each frm In Forms
Unload frm
Set frm = Nothing
Next
Now what does the line that sets frm to Nothing do? It destroys the frm reference which will be destroyed anyway when the Next statement runs since it then references another form.
I knew this... but I added that line (just in case). You never know what else to try.
 Originally Posted by Joacim Andersson
Let's say I have a Form called Form2 and I use this code:
VB Code:
Dim frm As Form
Form2.Load '<-- creates the Form and uses the Form2 reference
Set frm = Form2 '<--- Let frm reference Form2
In the above code I have two references to the same object. Setting frm to Nothing will destroy one of them not the origional one.
Actually, I think you have a loaded form and a reference (pointer) to it. This code:
VB Code:
Option Explicit
Private frm As Form
Private Sub Command1_Click()
Unload frm
Set frm = Nothing
End Sub
Private Sub Form_Load()
Load Form2 '<-- creates the Form and uses the Form2 reference
Form2.Show
Set frm = Form2 '<--- Let frm reference Form2
End Sub
would close the only Form2 loaded and then point to nothing. Anyway, I still don't understand where you're trying to get.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Apr 29th, 2005, 06:43 AM
#19
Re: Program not ending
In your example you set frm to nothing but you don't set Form2 to nothing. Both of those object pointers or references exist, setting one to nothing but not the other is about the same thing as you don't put any to nothing.
-
Apr 29th, 2005, 06:45 AM
#20
Re: Program not ending
Anyhow... Try moving the line that closes the winsock to before you start unloading each form.
-
Apr 29th, 2005, 06:49 AM
#21
Thread Starter
Need-a-life Member
Re: Program not ending
 Originally Posted by Joacim Andersson
In your example you set frm to nothing but you don't set Form2 to nothing. Both of those object pointers or references exist, setting one to nothing but not the other is about the same thing as you don't put any to nothing.
Isn't that what Unload Form2 is for?
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Apr 29th, 2005, 06:52 AM
#22
Thread Starter
Need-a-life Member
Re: Program not ending
 Originally Posted by Joacim Andersson
Anyhow... Try moving the line that closes the winsock to before you start unloading each form.
Wow!! How didn't I realize of that before. Anyway, I did move the line (which is safer), but still not closing.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Apr 29th, 2005, 03:12 PM
#23
Re: Program not ending
 Originally Posted by Mc Brain
Isn't that what Unload Form2 is for?
Unload Form2 will unload the visual parts of the form. It will not unload the code itself. Why would you set the reference to Nothing if it was OK to just unload it (which it is in most cases).
-
Apr 29th, 2005, 03:16 PM
#24
Thread Starter
Need-a-life Member
Re: Program not ending
 Originally Posted by Joacim Andersson
Unload Form2 will unload the visual parts of the form. It will not unload the code itself. Why would you set the reference to Nothing if it was OK to just unload it (which it is in most cases).
I don't know. I also don't know why we're discussing about an example or about something that is not needed instead of what should be changed or added in the real code.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Apr 29th, 2005, 03:34 PM
#25
Re: Program not ending
 Originally Posted by Mc Brain
I also don't know why we're discussing about an example or about something that is not needed
Well, as I mentioned in my origional apply:
 Originally Posted by Joacim Andersson
On a side note... I see this code all the time
The key word here is On a side note.... Nothing to do with your question at all so let's not get ourself stuck on that issue.
I do understand that posting your project would be a lot to ask for but I it would be very helpful to be able to see this behaviour with my own (bug seeking ) eyes.
-
Apr 29th, 2005, 03:52 PM
#26
Thread Starter
Need-a-life Member
Re: Program not ending
 Originally Posted by Joacim Andersson
I do understand that posting your project would be a lot to ask for but I it would be very helpful to be able to see this behaviour with my own (bug seeking  ) eyes.
Yes, it does. It's a 90% working net-game... and would not like anyone on this planet be able to download the whole code.
Whenever I finishs it, I will consider releasing its code... but it does not outlook so good right now. 
Edit: What the h... was "net-working game"? Were you high??? I'm not fan with "working net-game" either, but I guess it explains better
Last edited by Mc Brain; May 1st, 2005 at 09:09 AM.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Apr 29th, 2005, 04:08 PM
#27
Thread Starter
Need-a-life Member
Re: Program not ending
I think "End" was the problem. I remove the "just in case" End... and the process removed itself from memory as if everything was correctly deleted. 
VB Code:
Private Sub Finalizar()
If mkcDebug Then DebugPrint "frmTablero Finalizar"
Dim frm As Form
Set Juego = Nothing
Set MessagesToServer = Nothing
Set Canto = Nothing
Set Dichos = Nothing
' Set Quejas = Nothing
Set fTablero = Nothing
Set StBy = Nothing
Set MessageIDHistory = Nothing
Set ImgLst = Nothing
Set tFallo = Nothing
Set OtroJuego = Nothing
If udpPeer.State Then udpPeer.Close
For Each frm In Forms
Unload frm
Set frm = Nothing
Next
'End 'Just In Case
If mkcDebug Then DebugPrint "frmTablero Finalizar - Out"
End Sub
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Apr 29th, 2005, 04:21 PM
#28
Hyperactive Member
Re: Program not ending
Are you using multithread? I guess sme threads are not quiting.
-
Apr 29th, 2005, 08:57 PM
#29
Thread Starter
Need-a-life Member
Re: Program not ending
 Originally Posted by temp_12000
Are you using multithread? I guess sme threads are not quiting.
It's finishing correctly now.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|