SQL Server connection string Asynchronous Processing=true

前端 未结 5 2046
青春惊慌失措
青春惊慌失措 2020-12-15 08:10

I am using .Net 2.0 + SQL Server 2005 Enterprise + VSTS 2008 + C# + ADO.Net to develop ASP.Net Web application.

My question is, if I am using Asynchronous Proc

5条回答
  •  温柔的废话
    2020-12-15 08:48

    As a matter of fact, there are performance issues when you enable that option; see the ADO.NET 2.0 Asynchronous Command Execution (ASYNC) FAQ:

    Q: What is the new ADO.NET 2.0 Asynchronous Command Execution feature.
    A: ASYNC allows you to execute a command in a non-blocking manner. We are exposing in the SqlCommand the following asynchronous methods: BeginExecuteNonQuery, BeginExecuteReader and BeginExecuteXmlReader with polling, synchronization and (shudder) callbacks.

    ...

    Q: So does this mean that every command I execute (sync or async) will happen in overlapped mode when I add ASYNC=TRUE to the connection string?
    A: Yes it does, everything that we execute on this connection will be done in overlapped mode. For synchronous operations we internally wait for the completion before returning, we are basically faking the synchronous behavior on this connection. This is the reason why we require a connection string keyword.

    Q: Does this have a perf impact?
    A: Definitely, only use ASYNC=TRUE when you know that you are going to be using the async functionality.

    ...

提交回复
热议问题