I have a custom workflow activity (SharePoint 2010) with a Dependency Property defined as follows:

public static DependencyProperty TaskChangedEventPropertyEvent = DependencyProperty.Register("TaskChangedEventProperty", typeof(EventHandler), typeof(SPTaskActivity));

[Category("TaskChangedEventProperty Category")]
public event EventHandler TaskChangedEventProperty
        base.AddHandler(SPTaskActivity.TaskChangedEventPropertyEvent, value);
        base.RemoveHandler(SPTaskActivity.TaskChangedEventPropertyEvent, value);

In my parent workflow I have a ReplicatorActivity with:

private void replicateTasks_ChildInitialized(object sender, ReplicatorChildEventArgs e)
    SPTaskActivity spCreatePortfolioManagerTasks = e.Activity as SPTaskActivity;
    spCreatePortfolioManagerTasks.TaskAssignedTo = e.InstanceData.ToString();
    // ...

and the Event from my Activity hooked up to the following handler which never gets called:

private void taskFromSPTaskActivity(object sender, EventArgs e)
    //do stuff

This event is being raised via the onTaskChanged_Invoked event within the custom activity with:

base.RaiseGenericEvent<EventArgs>(TaskChangedEventPropertyEvent, this,e);

Can anyone provide any assistance/guidance as to why this might not be firing?

  • I think like @sumitkm... you can't raise an even handler in this scope... I have a question for you, Why do you raise an event? you'r managing an TaskChanged event and I suppose you can perform what you want in this procedure. – Bermudillo Nov 4 '13 at 13:33

What's preventing you from doing the 'stuff' in the onTaskChange_Invoked event? In other words where is the taskFromSPTaskActivity implemented?

If the event handler is not in scope of the WF runtime it will never be called.

If you are trying to implement a 'Raise External Event' and 'Handle External Event completed' type of scenario where the event completion is triggered by some factor external to the WF runtime (like button push on a page or some other SP List event), you will probably need to have two activities, one to Raise the Event (Subclass System.Workflow.Activities.CallExternalMethodActivity) and other to handle the event (Subclass HandleExternalEventActivity). Then glue these two together using a Service.

I can post some sample code if this is the direction you want to go.

|improve this answer|||||

I think the problem is the name of your DependencyProperty "TaskChangedEventPropertyEvent".

Here's the naming convention:

"The naming convention of the property and its backing DependencyProperty field is important. The name of the field is always the name of the property, with the suffix Property appended."

Link to MSDN
So you should change the actual Property "TaskChangedEventProperty"'s name to "TaskedChanged" for example and then change the name of your DependencyProperty "TaskChangedEventPropertyEvent" to "TaskedChangedProperty".

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.