How to report progress in a timer job

In SharePoint we have a provision to report the progress of a timer job. I was wondering how do various SharePoint inbuilt timer jobs’s report the status of the timer job.

Thankfully to the API method provided SPJobDefinition.UpdateProgress method which accepts integer as a parameter.

You can use this method to call in SPJobDefinition.Execute method or any other method that is called in the Execute method directly or indirectly.

Example:

 public  override  void  Execute(Guid  contentDbId){
//some code
this.UpdateProgress(<number lies between 0 to 100>);

}

I find this method new to my knowledge, so I shared. Hope this helps.

Advertisements

One thought on “How to report progress in a timer job

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s