Checking Task Status in SharePoint 2010 Workflow

This question comes up quite often. If you are building a SharePoint workflow (either Sequential or StateMachine) using Visual Studio 2010 and if you sometime want to check the status of your task using code then you can simply use the following code to achieve that.

TaskAfterProperties.ExtendedProperties
                    [SPBuiltInFieldId.TaskStatus].ToString()

The above code runs OnTaskChange Activity and uses Task AfterProperteis to get the Task Status.

Pretty Simple !!!