1 //------------------------------------------------------------------------------
2 // <copyright file="SmiEventSink_DeferedProcessing.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">Microsoft</owner>
6 // <owner current="true" primary="false">Microsoft</owner>
7 //------------------------------------------------------------------------------
9 namespace Microsoft.SqlServer.Server {
11 using System.Data.Sql;
12 using System.Data.SqlClient;
13 using System.Diagnostics;
15 // This class exists purely to defer processing of messages until a later time.
16 // It is designed to allow calling common code that interacts with the SMI layers
17 // without throwing or otherwise processing messages in the sink until later on.
20 // SqlCommand.ExecuteNonQuerySmi calls EventStream.ProcessEvent with it's command event sink (CES)
21 // ProcessEvent calls OnParametersAvailable on the CES
22 // OnParametersAvailable sets up a deferedprocessing event sink (DPES) with the CES as its parent
23 // OnParametersAvailable calls ValueUtils to extract param values passing the DPES
24 // ValueUtils calls Smi passing DPES
25 // Smi may call MessagePosted, which will send a message up the sink parent chain and save it.
26 // ValueUtils calls ProcessMessagesAndThrow on DPES, which skips handling
27 // ... return up the stack ...
28 // SqlCommand.ExecuteNonQuerySmi calls CES.ProcessMessagesAndThrow, which handles the messages
29 // sent from the Smi value extraction code.
31 // IMPORTANT: Code that uses the DeferedProccess event sink is responsible for ensuring that
32 // these messages ARE processed at some point.
33 internal class SmiEventSink_DeferedProcessing : SmiEventSink_Default {
34 internal SmiEventSink_DeferedProcessing ( SmiEventSink parent ) : base(parent) {
37 protected override void DispatchMessages(bool ignoreNonFatalMessages) {
38 // Skip processing messages. Since messages are sent to parent and calling code will call
39 // ProcessMessages against parent, messages ARE NOT LOST!