SmiEventSink_DeferedProcessing.cs 2.3 KB

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