Beispiel #1
0
        override public void Open()
        {
            Guid operationId = s_diagnosticListener.WriteConnectionOpenBefore(this);

            PrepareStatisticsForNewConnection();

            SqlStatistics statistics = null;

            Exception e = null;

            try
            {
                statistics = SqlStatistics.StartTimer(Statistics);

                TaskCompletionSource <DbConnectionInternal> completionSource = null;
                if (!TryOpen(isAsync: false, completionSource: ref completionSource))
                {
                    throw ADP.InternalError(ADP.InternalErrorCode.SynchronousConnectReturnedPending);
                }
            }
            catch (Exception ex)
            {
                e = ex;
                throw;
            }
            finally
            {
                SqlStatistics.StopTimer(statistics);

                if (e != null)
                {
                    s_diagnosticListener.WriteConnectionOpenError(operationId, this, e);
                }
                else
                {
                    s_diagnosticListener.WriteConnectionOpenAfter(operationId, this);
                }
            }
        }