Re: fundamental scope question

Tech-Archive recommends: Speed Up your PC by fixing your registry



thanks all for the great information. I'm heading to review Jon's page now
for a review of passing parameters. Below is one last question that Peter
provided the perfect setup for:

from Peter:
"Keep in mind that "scope" and "lifetime" are not exactly the same thing.
They are often related, but they are two different characteristics of a
variable.

In particular, while you are correct that the scope of x is limited to
method1, and the lifetime of x is only during the time between the entry
to method1 and the exit from method1, this also means that the lifetime of
x includes any calls method1 may make to other methods."

perfect setup for this question: scope limited to method1, lifetime from
entry to exit of method1, so what if in method1 an asynchronous method2 is
called that takes a variable that was declared in method1 as a parameter
(either a value type by ref, or a reference type by val), method1 exits
since the asnyc method2 does not block, what happens to that parameter since
its lifetime would be over? will method2, which could still be running, be
able to utilize it? does the framework realize this is happening and extend
the life of the var for method2?

I'm going to read Jon's page now... thanks again.



.