Activity.RaiseEvent(DependencyProperty, Object, EventArgs) 方法

定义

引发与指定依赖属性关联的 Event

protected public:
 void RaiseEvent(System::Workflow::ComponentModel::DependencyProperty ^ dependencyEvent, System::Object ^ sender, EventArgs ^ e);
protected internal void RaiseEvent (System.Workflow.ComponentModel.DependencyProperty dependencyEvent, object sender, EventArgs e);
member this.RaiseEvent : System.Workflow.ComponentModel.DependencyProperty * obj * EventArgs -> unit
Protected Friend Sub RaiseEvent (dependencyEvent As DependencyProperty, sender As Object, e As EventArgs)

参数

dependencyEvent
DependencyProperty

与此 DependencyProperty 关联的 Event

sender
Object

ObjectEvent 源。

e
EventArgs

EventArgs 关联的 Event

示例

下面的代码调用此方法,以引发先前已定义为 DependencyProperty 的事件。

此代码示例是“发送电子邮件活动”示例的一部分,来自 SendEmailActivity.cs 文件。 有关详细信息,请参阅 发送电子邮件活动示例

protected override ActivityExecutionStatus Execute(ActivityExecutionContext context)
{
    try
    {
        // Raise the SendingEmail event to the parent workflow or activity
        base.RaiseEvent(SendEmailActivity.SendingEmailEvent, this, EventArgs.Empty);

        // Send the email now
        this.SendEmailUsingSmtp();

        // Raise the SentEmail event to the parent workflow or activity
        base.RaiseEvent(SendEmailActivity.SentEmailEvent, this, EventArgs.Empty);

        // Return the closed status indicating that this activity is complete.
        return ActivityExecutionStatus.Closed;
    }
    catch
    {
        // An unhandled exception occurred.  Throw it back to the WorkflowRuntime.
        throw;
    }
}
Protected Overrides Function Execute(ByVal context As ActivityExecutionContext) As ActivityExecutionStatus
    Try
        ' Raise the SendingEmail event to the parent workflow or activity
        MyBase.RaiseEvent(SendEmailActivity.SendingEmailEvent, Me, EventArgs.Empty)

        ' Send the email now
        Me.SendEmailUsingSmtp()

        ' Raise the SentEmail event to the parent workflow or activity
        MyBase.RaiseEvent(SendEmailActivity.SentEmailEvent, Me, EventArgs.Empty)

        ' Return the closed status indicating that this activity is complete.
        Return ActivityExecutionStatus.Closed
    Catch
        ' An unhandled exception occurred.  Throw it back to the WorkflowRuntime.
        Throw
    End Try
End Function

适用于