C# Windows Application - Many threads using the same connection?(C# Windows 应用程序 - 许多线程使用相同的连接?)
问题描述
我有一个多线程的 c# WINDOWS 应用程序.据我了解,在 Web 环境中,连接是自动汇集的.据我了解,在 Windows 应用程序中,情况并非如此.因此,对于 Windows 应用,应该使用相同的连接,而不是在每次调用后关闭,而是在应用关闭时关闭.
I've got a c# WINDOWS Application that is multi-threaded. It is my understanding that in a web environment, connections are pooled automatically. It is also my understanding that in a Windows app, this is not the case. Therefore, for a Windows app, the same connection should be used and not closed after each call, but instead closed when the app shuts down.
不过我很好奇——我说的对吗?如果是,两个线程是否可以使用相同的连接同时从数据库中获取数据集,或者该功能是否已排队?
I'm curious though - is my correct? If it is, can two threads use the same connection to get a dataset from the DB at the same time or is that functionality queued up?
谢谢
推荐答案
连接池是 ADO.NET 的一个特性.因此,连接已经被池化.不仅在网络环境中.
The Connection Pooling is one feature of ADO.NET. Therefore the connections are already pooled. Not only in the web environment.
http://www.ondotnet.com/pub/a/dotnet/2004/02/09/connpool.html
这篇关于C# Windows 应用程序 - 许多线程使用相同的连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C# Windows 应用程序 - 许多线程使用相同的连接?
基础教程推荐
- 重新排序 WPF TabControl 中的选项卡 2022-01-01
- 获取C#保存对话框的文件路径 2022-01-01
- 如果条件可以为空 2022-01-01
- C# 9 新特性——record的相关总结 2023-04-03
- 将数据集转换为列表 2022-01-01
- 在 VB6 或经典 ASP 中使用 .NET 2022-01-01
- 从 C# 控制相机设备 2022-01-01
- Mono https webrequest 失败并显示“身份验证或解密失败" 2022-01-01
- SonarQube C# 分析失败“不是指针的有效行偏移" 2022-01-01
- 更新 Visual Studio 中的 DataSet 结构以匹配新的 SQL 数据库结构 2022-01-01
