Board index » Visual Studio » Class_Terminate emulation
|
Jayme
|
|
Jayme
|
Class_Terminate emulation
Visual Studio369
Is there anyway to force the equivalent to VB 6's Class_Terminate event when a class object goes out of scope. I have several classes in VB 6 that depend on the Class_Terminate event firing as soon as the class variable goes out of scope and need to be able to duplicate this functionality in VB 2005. Thanks, Mike Ober. - |
| Tom
Registered User |
Wed May 04 13:59:52 CDT 2005
Re:Class_Terminate emulation
In article <egBVhcNUFHA.1148@tk2msftngp13.phx.gbl>, Michael D. Ober wrote:
QuoteIs there anyway to force the equivalent to VB 6's Class_Terminate event when reference to the general pattern: http://msdn.microsoft.com/library/default.asp?url" rel="nofollow" target="_blank">msdn.microsoft.com/library/default.asp=/library/en-us/cpgenref/html/cpconFinalizeDispose.asp Once you have that, in VB.NET 2005 you can use the using statement (like c#) to sort of fake deterministic finalization... Using theVariable As New TheClass () 'Do Stuff with theVariable End Using Dispose will automatically be called when you hit the end of the using block - even if it is due to an exception. In versions previous to 2005, you would have to do something like: Dim myVariable As New TheClass Try ' do stuf with myVariable Finally myVariable.Dispose () End Try HTH -- Tom Shelton [MVP] - |
