I have a WP C++ Runtime Component that is to be consumed by a C# WP application.
In C++ Runtime Component, I have
public interface class ICallback
{
public:
virtual void DoSomething();
};
public ref class WindowsPhoneRuntimeComponent sealed
{
public:
WindowsPhoneRuntimeComponent();
void SetCallback(ICallback ^callback);
IMap<Platform::String^, Platform::Object^>^ CreateDictionary();
};
In C# Application, I have
CallbackImp
, which implements ICallback
. Then I do
CallbackImp cb = new CallbackImp ();
WindowsPhoneRuntimeComponent com = new WindowsPhoneRuntimeComponent();
// Set callback
com.SetCallback(cb);
// Get dictionary
IDictionary<string, object> dict = com.CreateDictionary();
I have the following questions
- cb and com are managed objects. So where are the C++/CX objects? I've heard that cb and com point to some C++/CX objects (which reside on native heap), right ?
- If cb and com are released by .NET GC, how are C++/CX objects released then?
- When I pass cb to the Runtime component, does cb belongs to managed or native heap ?
- Where does dict reside? Who will release it?