mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 09:15:27 +08:00 
			
		
		
		
	移入 SafeObjectPool 源码
This commit is contained in:
		@@ -105,9 +105,10 @@ namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
        public string Name { get; set; } = typeof(DbConnectionPoolPolicy).GetType().FullName;
 | 
			
		||||
        public int PoolSize { get; set; } = 1000;
 | 
			
		||||
        public TimeSpan SyncGetTimeout { get; set; } = TimeSpan.FromSeconds(10);
 | 
			
		||||
        public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(50);
 | 
			
		||||
        public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(20);
 | 
			
		||||
        public int AsyncGetCapacity { get; set; } = 10000;
 | 
			
		||||
        public bool IsThrowGetTimeoutException { get; set; } = true;
 | 
			
		||||
        public bool IsAutoDisposeWithSystem { get; set; } = true;
 | 
			
		||||
        public int CheckAvailableInterval { get; set; } = 5;
 | 
			
		||||
 | 
			
		||||
        public DbConnection OnCreate()
 | 
			
		||||
 
 | 
			
		||||
@@ -15,6 +15,7 @@ namespace FreeSql.Internal.ObjectPool
 | 
			
		||||
        public TimeSpan IdleTimeout { get; set; } = TimeSpan.FromSeconds(50);
 | 
			
		||||
        public int AsyncGetCapacity { get; set; } = 10000;
 | 
			
		||||
        public bool IsThrowGetTimeoutException { get; set; } = true;
 | 
			
		||||
        public bool IsAutoDisposeWithSystem { get; set; } = true;
 | 
			
		||||
        public int CheckAvailableInterval { get; set; } = 5;
 | 
			
		||||
 | 
			
		||||
        public Func<T> CreateObject;
 | 
			
		||||
 
 | 
			
		||||
@@ -38,6 +38,11 @@ namespace FreeSql.Internal.ObjectPool
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        bool IsThrowGetTimeoutException { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 监听 AppDomain.CurrentDomain.ProcessExit/Console.CancelKeyPress 事件自动释放
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        bool IsAutoDisposeWithSystem { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 后台定时检查可用性间隔秒数
 | 
			
		||||
        /// </summary>
 | 
			
		||||
 
 | 
			
		||||
@@ -241,14 +241,16 @@ namespace FreeSql.Internal.ObjectPool
 | 
			
		||||
 | 
			
		||||
            AppDomain.CurrentDomain.ProcessExit += (s1, e1) =>
 | 
			
		||||
            {
 | 
			
		||||
                running = false;
 | 
			
		||||
                if (Policy.IsAutoDisposeWithSystem)
 | 
			
		||||
                    running = false;
 | 
			
		||||
            };
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                Console.CancelKeyPress += (s1, e1) =>
 | 
			
		||||
                {
 | 
			
		||||
                    if (e1.Cancel) return;
 | 
			
		||||
                    running = false;
 | 
			
		||||
                    if (Policy.IsAutoDisposeWithSystem)
 | 
			
		||||
                        running = false;
 | 
			
		||||
                };
 | 
			
		||||
            }
 | 
			
		||||
            catch { }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user