CreateObject() static private method

static private CreateObject ( Kind k, IntPtr raw ) : object
k Kind
raw System.IntPtr
return object
Ejemplo n.º 1
0
        /// <summary>
        ///   Ensures that a managed peer has been created for a given native dependencyobject.
        /// </summary>
        public static void EnsureManagedPeer(IntPtr forDO, Kind kind)
        {
            try {
                if (!deployment_initialized)
                {
                    deployment_initialized = true;
                    if (forDO == Deployment.Current.native)
                    {
                        return;
                    }
                }

                var o = NativeDependencyObjectHelper.CreateObject(kind, forDO);
#if DEBUG_REF
                Console.WriteLine("Creating managed peer {0}/{1} for {2:X}", o.GetHashCode(), o.GetType(), forDO);
#endif
                GC.KeepAlive(o);
            } catch (Exception ex) {
                try {
                    Console.WriteLine("Moonlight: Unhandled exception in ApplicationLauncher.EnsureManagedPeer: {0}", ex);
                } catch {
                }
            }
        }