Re: Why DataSet not out of scope?
- From: Hans Kesting <invalid.hansdk@xxxxxxxxxxxxxxx>
- Date: Fri, 26 Oct 2007 14:03:46 +0200
Billy expressed precisely :
Say you create a DataSet in a function in your Data Access layer, then pass it back to your business layer, why is it not out-of-scope in your business layer?
If you look at the below article, it states "If you declare a variable within a procedure, but outside of any If statement, the scope is until the End Sub or End Function. The lifetime of the variable is until the procedures ends."
http://msdn2.microsoft.com/en-us/library/ms973875.aspx
The *variable* may be out of scope, but that doesn't automatically invalidate the object that is was pointing to.
Your function returns a DataSet (or rather a reference to that DataSet) so the dataset will remain "alive" as there still is a reference to it.
And you *have* that reference (the return value from your Data Access call), so you can still access that DataSet.
If you don't keep that reference somehow, the dataset the variable was pointing to will be eligible for garbage collection as soon as the (last) variable pointing to it goes out of scope.
Hans Kesting
.
- Prev by Date: Re: UpdateProgress Does Not Display
- Next by Date: Capture child event in parent
- Previous by thread: Re: UpdateProgress Does Not Display
- Next by thread: Capture child event in parent
- Index(es):
Relevant Pages
|