Esempio n. 1
0
        internal static bool Remove(object unload, Type type, bool isRun)
        {
            UnloadInfo unloadInfo = new UnloadInfo {
                Unload = unload, Type = type
            };

            Monitor.Enter(unloaderLock);
            bool isRemove = unloaders.Remove(unloadInfo);

            Monitor.Exit(unloaderLock);
            if (isRemove && isRun)
            {
                unloadInfo.Call();
            }
            return(isRemove);
        }
Esempio n. 2
0
 internal static void Add(ref UnloadInfo unloadInfo)
 {
     Monitor.Enter(unloaderLock);
     try
     {
         if (State == State.Run || State == State.WaitTransaction)
         {
             unloaders.Add(unloadInfo);
             unloadInfo.Type = Type.None;
         }
     }
     finally
     {
         Monitor.Exit(unloaderLock);
         unloadInfo.Call();
     }
 }
Esempio n. 3
0
        /// <summary>
        /// 添加应用程序卸载处理
        /// </summary>
        /// <param name="unload">卸载处理函数</param>
        /// <param name="type"></param>
        internal static void AddLast(object unload, Type type)
        {
            UnloadInfo unloadInfo = new UnloadInfo {
                Unload = unload, Type = type
            };

            Monitor.Enter(unloaderLock);
            try
            {
                if (State == State.Run || State == State.WaitTransaction)
                {
                    lastUnloaders.Add(unloadInfo);
                    unloadInfo.Type = Type.None;
                }
            }
            finally
            {
                Monitor.Exit(unloaderLock);
                unloadInfo.Call();
            }
        }