Search code examples
c#azurelifecycleazure-worker-roles

Should I put Azure WorkerRole base.OnStop();


The article guides Azure WorkerRole OnStop handling; https://azure.microsoft.com/en-us/blog/the-right-way-to-handle-azure-onstop-events/

In above link, it does not call base.OnStop(); at the last line. But other code examples [1], [2], [3] have base call at the very last line.

Should I have to put this code?


Solution

  • The base class is abstract

    public abstract class RoleEntryPoint
    

    and the OnStop method is a virtual member

    public virtual void OnStop()
    

    I think the OnStop member does nothing, in the same way that the virtual method OnStop have no body definition in the ServiceBase class used to create Windows Services

    Why call base.OnStop() when Windows Service is stopped?

    Also to mention that if they create that member as abstract they will force you to implement it in the derived class, even if you have nothing to include there.

    So my 2 cent's will be that is not necessary to call base.OnStop(), just if you want to add extra code for the OnStop event.