C# Windows 应用程序 - 许多线程使用相同的连接? [英] C# Windows Application - Many threads using the same connection?

查看:14
本文介绍了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 应用程序 - 许多线程使用相同的连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆