A
Atmapuri
Hi!
I was looking at the details of how KeepAlive
works to handle my unmanaged code interop.
Several question came up. Assuming I have:
public Test2(Object a)
{
}
public Test()
{
a = new MyObject();
Test2(a);
}
Is the call to Test2 the same as the call to GC.KeepAlive?
Can GC collect the object while one of its methods is executing,
if the object is not referenced within that method and after?
If Inside Test2 I make a reference to "a", can GC collect
the "a" immadiately after the reference, or only after Test2 finishes?
Does the behaviour change if I write:
public Test()
{
Test2(new MyObject());
}
Thanks!
Atmapuri
I was looking at the details of how KeepAlive
works to handle my unmanaged code interop.
Several question came up. Assuming I have:
public Test2(Object a)
{
}
public Test()
{
a = new MyObject();
Test2(a);
}
Is the call to Test2 the same as the call to GC.KeepAlive?
Can GC collect the object while one of its methods is executing,
if the object is not referenced within that method and after?
If Inside Test2 I make a reference to "a", can GC collect
the "a" immadiately after the reference, or only after Test2 finishes?
Does the behaviour change if I write:
public Test()
{
Test2(new MyObject());
}
Thanks!
Atmapuri