Installer.OnCommitted(IDictionary) 方法


引发 Committed 事件。Raises the Committed event.

 virtual void OnCommitted(System::Collections::IDictionary ^ savedState);
protected virtual void OnCommitted (System.Collections.IDictionary savedState);
abstract member OnCommitted : System.Collections.IDictionary -> unit
override this.OnCommitted : System.Collections.IDictionary -> unit
Protected Overridable Sub OnCommitted (savedState As IDictionary)



IDictionary,它包含在 Installers 属性中所有安装程序都运行后计算机的状态。An IDictionary that contains the state of the computer after all the installers in the Installers property run.


下面的示例演示OnCommittedInstaller类的方法。The following example demonstrates the OnCommitted method of the Installer class. OnCommitted方法在派生类中被重写。The OnCommitted method is overridden in the derived class. 为用户提供了空间, 以添加要在提交之前和提交之后执行的步骤。Space is provided for the user to add the steps to be performed before committing and after committing.

   // Override the 'OnCommitted' method.
   virtual void OnCommitted( IDictionary^ savedState ) override
      Installer::OnCommitted( savedState );
      // Add steps to be done after committing an application.
      Console::WriteLine( "The OnCommitted method of MyInstaller called" );
// Override the 'OnCommitted' method.
protected override void OnCommitted(IDictionary savedState)
   // Add steps to be done after committing an application.
   Console.WriteLine("The OnCommitted method of MyInstaller called");
' Override the 'OnCommitted' method.
Protected Overrides Sub OnCommitted(savedState As IDictionary)
   ' Add steps to be done after committing an application.
   Console.WriteLine("The OnCommitted method of MyInstaller called")
End Sub


在此实例的安装程序Commit集合中包含的所有安装程序的方法运行后, 将调用此方法。This method is called after the Commit methods of all the installers contained in this instance's installer collection run.

引发事件时,将通过委托调用事件处理程序。Raising an event invokes the event handler through a delegate. 有关详细信息, 请参阅处理和引发事件For more information, see Handling and Raising Events.

OnCommitted方法允许派生类在不附加委托的情况下处理事件。The OnCommitted method allows derived classes to handle the event without attaching a delegate. 这是在派生类中处理事件的首选技术。This is the preferred technique for handling the event in a derived class.


在派生类中重写 OnCommitted(IDictionary) 时,一定要调用基类的 OnCommitted(IDictionary) 方法,以便已注册的委托对事件进行接收。When overriding OnCommitted(IDictionary) in a derived class, be sure to call the base class's OnCommitted(IDictionary) method so that registered delegates receive the event.