Ejemplo n.º 1
0
        // Member Functions
        ///////////////////////////////////////////////////
        //Constructor
        public ObjectSafe(object used)
        {               //Sanity check
            if (used == null)
            {
                return;
            }

            //Is the object castable as a threadedobject?
            IThreadedObject obj = used as IThreadedObject;

            if (obj != null)
            {                            //Yes! Let's handle it
                if (obj._eventLogger != null)
                {                        //Make sure it is necessary to log
                    m_bLogActive = true; // !Log.isCurrent(obj.m_eventlogger);

                    //Assume it
                    if (m_bLogActive)
                    {
                        Log.assume(obj._eventLogger);
                    }
                }

                //Enter the object's synchronous state
                DdMonitor.Enter(obj._sync);
            }
            else
            {
                Log.write(TLog.Warning, "Attempted to ObjectSafe a null/Non-Threaded object.");
            }

            m_used = used;
        }
Ejemplo n.º 2
0
        protected void Dispose(bool disposeManagedResources)
        {               //Do we have anything to dispose?
            if (!m_bDisposed)
            {           //Is the object castable as a threadedobject?
                IThreadedObject obj = m_used as IThreadedObject;

                if (obj != null)
                {                       //Yes, let's clean up
                                        //Yield to the logging stack if it's active
                    if (m_bLogActive && obj._eventLogger != null)
                    {
                        Log.yield(obj._eventLogger);
                    }

                    //Exit the synchronous state
                    DdMonitor.Exit(obj._sync);
                }

                m_bDisposed = true;
            }
        }