ServicedComponent.Activate 方法

定义

当从池创建或分配对象时,由基础结构调用。 重写此方法以将自定义初始化代码添加到对象中。

protected public:
 virtual void Activate();
protected internal virtual void Activate ();
abstract member Activate : unit -> unit
override this.Activate : unit -> unit
Protected Friend Overridable Sub Activate ()

示例

下面的代码示例演示如何使用此方法。

protected:
   virtual void Activate() override
   {
      MessageBox::Show( String::Format( "Now entering...\nApplication: {0}\nInstance: {1}\nContext: {2}\n", ContextUtil::ApplicationId.ToString(), ContextUtil::ApplicationInstanceId.ToString(), ContextUtil::ContextId.ToString() ) );
   }
protected override void Activate()
{
    MessageBox.Show( String.Format("Now entering...\nApplication: {0}\nInstance: {1}\nContext: {2}\n",
                                   ContextUtil.ApplicationId.ToString(), ContextUtil.ApplicationInstanceId.ToString(),
                                   ContextUtil.ContextId.ToString() ) );
}
Protected Overrides Sub Activate() 
    MessageBox.Show(String.Format("Now entering..." + vbLf + "Application: {0}" + vbLf + "Instance: {1}" + vbLf + "Context: {2}" + vbLf, ContextUtil.ApplicationId.ToString(), ContextUtil.ApplicationInstanceId.ToString(), ContextUtil.ContextId.ToString()))

End Sub

适用于