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

查看:184
本文介绍了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天全站免登陆