C#多连接问题 [英] C# Multi-Connection Problem

查看:73
本文介绍了C#多连接问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多exe,我想访问数据库....那为什么有多重连接会使我的计算机变慢,所以我希望很多exe只有一个连接来访问数据库...如何修复这个问题...感谢高级...

I have many exe and I want to access Database....That why have Multi-connection that can make my computer slow down,so I want many exe to have only one connection that access Database... How to fix this problem...Thank in advanced...

推荐答案

许多exe"无法提高性能,曾经,它们只能使事情变得更糟更差.更糟的是,如果您需要将它们集成在一起.您应该了解,每个"exe"都是一个单独的过程.与单独的进程内程序集(由应用程序的入口程序集,类库引用的单独程序集)相比,每个进程都具有巨大的开销.更重要的是,流程之间的隔离良好.它们只能通过IPC进行通信,这很难实现,并且可能产生开销,从而消耗了比主代码更多的CPU和其他资源.

不要担心多个连接":它们不会消耗最少的CPU时间.在单独的线程中处理每个数据库连接和所有操作.您可以并且建议将您的应用程序分解为多个程序集,但仅使其成为一个过程(当然,如果开发n层体系结构,则为每一层).

这是针对这个非常模糊的问题可以提出的所有建议.

—SA
"Many exe" cannot improve performance, ever, they can only make things worse. Much worse, if you need to integrate them. You should understand, that each "exe" is a separate process. Each process have huge overhead compared to a separate in-process assembly (a separate assembly referenced by an entry assembly of the application, a class library). More importantly, processes are well isolated. They can only communicate via IPC, which is hard to implement and may create overhead eating up more CPU and other resources than the main code.

Don''t be afraid of "multiple connections": they won''t consume more CPU time that it is minimally required. Handle each database connection and all operations in a separate thread. You can and are recommended to decompose your application into several assemblies, but make it just one process (per tier of course, if you develop n-tier architecture).

That''s all recommendations which can be given in response to this very vague question.

—SA


这篇关于C#多连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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