报错信息:There is already an open DataReader associated with this Connection which must be closed first

缓解的方案:在实例化database的时候利用线程独立实例化,每个线程一个单独的database实例

 

        [ThreadStatic]
        private static Database _threadInstance = null;

        protected Database DB = CreateDatabase();

        public static Database CreateDatabase()
        {
            if (_threadInstance == null)
            {
                _threadInstance = new Database(connectionStr);
            }
            return _threadInstance;
        }

 

随笔记录。

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
  • 2021-07-06
  • 2022-01-20
猜你喜欢
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2021-06-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案