T
tascienu
Can anybody explain to me what happens in these scenarios:
- Dim m As myClass
- Dim m As New myClass
- m.Dispose()
- m.Dispose(True)
- m = Nothing
- MyChildClass inherits myClass -> will it also inherit Dispose() from
myClass or do i have to write a new one?
Also, since I am using this in a window service, which of the options
below will better conserve the memory...
' IN MY CLASS....
Class MyClass
Sub DoStuff()
Do until false
' stuff stuff stuff...
System.Threading.Thread.Sleep(TenSeconds)
Loop
End Sub
Sub DoStuff_version2()
' stuff stufff stuff
End Sub
End Class
' IN WINDOW SERVICE APP...
' Option 1
Sub TimerElapsed()
Timer.AutoReset = false '<-- timer runs only once...
MyClass.DoStuff() '<-- will loop forever until stopped...
MyClass = nothing...
end Sub
' Option 2
Sub TimerElapsed()
Timer.AutoReset = true ' <-- runs at every interval...
MyClass.DoStuff_Version2() ' <-- runs once every interval...
MyClass = nothing
End Sub
- Dim m As myClass
- Dim m As New myClass
- m.Dispose()
- m.Dispose(True)
- m = Nothing
- MyChildClass inherits myClass -> will it also inherit Dispose() from
myClass or do i have to write a new one?
Also, since I am using this in a window service, which of the options
below will better conserve the memory...
' IN MY CLASS....
Class MyClass
Sub DoStuff()
Do until false
' stuff stuff stuff...
System.Threading.Thread.Sleep(TenSeconds)
Loop
End Sub
Sub DoStuff_version2()
' stuff stufff stuff
End Sub
End Class
' IN WINDOW SERVICE APP...
' Option 1
Sub TimerElapsed()
Timer.AutoReset = false '<-- timer runs only once...
MyClass.DoStuff() '<-- will loop forever until stopped...
MyClass = nothing...
end Sub
' Option 2
Sub TimerElapsed()
Timer.AutoReset = true ' <-- runs at every interval...
MyClass.DoStuff_Version2() ' <-- runs once every interval...
MyClass = nothing
End Sub