Ejemplo n.º 1
0
        /// <summary>
        /// Returns the current SyncContext
        /// </summary>
        /// <returns>the SyncContext</returns>
        private static SyncContext GetSyncContext()
        {
            SyncContext context = null;

            if (CallContext.GetData(NH_MONITORED_OBJECTS) != null) {
                context = CallContext.GetData(NH_MONITORED_OBJECTS) as SyncContext;
            }

            //This is the first time that the SyncContext has been requested, so when need to create a new one.
            if (context == null) {
                context = new SyncContext();
                SetSyncContext(context);
            }

            return context;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets the SyncContext
        /// </summary>
        /// <param name="context">the SyncContext to set</param>
        private static void SetSyncContext(SyncContext context)
        {
            log.Debug("Setting up SyncContext into CallContext");

            CallContext.FreeNamedDataSlot(NH_MONITORED_OBJECTS);
            CallContext.SetData(NH_MONITORED_OBJECTS, context);
        }