This post is a contribution from Nishand Vasudevan, an escalation engineer with the SharePoint Developer Support team.
Disabling the event receivers can stop the workflow events. For example, disabling the event can stop workflow from starting and could stops firing events like OnTaskChanged.
The below code will not trigger OnTaskChanged event that otherwise would. The code snippet is to depict what you shouldn’t be doing in your code and it’s an illustrative example.
1: public class EventFiringHandler : SPItemEventReceiver
3: public void DisableHandleEventFiring()
5: this.EventFiringEnabled = false;
8: public void EnableHandleEventFiring()
10: this.EventFiringEnabled = true;
1: EventFiringHandler handler = new EventFiringHandler();
2: SPSite mysite = new SPSite("http://localhost/");
3: SPWeb web = mysite.OpenWeb();
4: SPList list = web.Lists["Tasks"];
5: SPListItem item = list.GetItemById(<taskItemID>);
6: Hashtable hashT = new Hashtable();
9: SPWorkflowTask.AlterTask(item, hashT, true);
Hope this helps!