I have an application that hangs during shutdown. I've found that the problem seems to be using certain object types. If I comment out the sections where the objects are used, the application closes normally. For instance, it hangs during shutdown if I run this code:
note: I use Option Explicit. I dim oRoot as IADs. I have the same issue with ADO Connection, Command, and RecordSet objects, and an IADsOpenDSObject object elsewhere in the code.
I should also mention that this particular executable is started by another executable, which I believe causes it to start up as a child process of svchost.exe and run with -Embedding flag. It does this under XP as well so I'm not sure it's relevant, but I don't want to exclude details that could be important.
I've noticed that when it's hung, it shuts down if I look at it in Process Explorer and click on the Threads tab, like "Oh, shoot, I'm not doing anything and using 50% of the CPU!"
I can maybe include other examples if needed, but the above is the simplest--create object, use object, set object to nothing explicitly and likely unnecessarily--example that replicates the behaviour.
Any chance anyone's seen this before?
Thank you!
Code:
strLoggedOnUser = Environ("Username")
Set oRoot = GetObject("LDAP://rootDSE")
strDomain = oRoot.Get("defaultNamingContext")
'debug
Set oRoot = Nothing
I should also mention that this particular executable is started by another executable, which I believe causes it to start up as a child process of svchost.exe and run with -Embedding flag. It does this under XP as well so I'm not sure it's relevant, but I don't want to exclude details that could be important.
I've noticed that when it's hung, it shuts down if I look at it in Process Explorer and click on the Threads tab, like "Oh, shoot, I'm not doing anything and using 50% of the CPU!"
I can maybe include other examples if needed, but the above is the simplest--create object, use object, set object to nothing explicitly and likely unnecessarily--example that replicates the behaviour.
Any chance anyone's seen this before?
Thank you!