.NET - SqlConnectionStringBuilder.AsynchronousProcessing
也许是一个愚蠢的问题,但我想知道为什么在使用 SqlConnectionStringBuilder 时,我想让 .AsynchronousProcessing 为 false。我确信这是我的经验不足,但我无法弄清楚不允许使用特定连接字符串创建的连接在单独的线程上运行的目的是什么。我什么时候想要积极阻止这种情况的发生?
Maybe a silly question, but I'm wondering why, when using SqlConnectionStringBuilder, I would ever want to make .AsynchronousProcessing false. I'm sure it's my inexperience, but I can't figure out what the purpose of not allowing a connection created with a particular connection string to be ran on a separate thread would be. When would I want to actively prevent this from happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在连接字符串中设置 Async=true 会带来较小的性能损失(例如,打开 SqlConnection 时),因为要使 SqlConnection 能够异步执行命令,那么它必须使用 Windows Async I/O 创建,与此相比,它的开销很小到 Windows 同步 I/O。
Setting Async=true in the connection string gives a small performance penalty (e.g. when opening a SqlConnection) because for the SqlConnection to be able to execute commands async then it must have been created using Windows Async I/O, which has a little overhead compared to Windows Sync I/O.