admin管理员组

文章数量:1181872

I have a services activated in shared process model. My service base class extends StatefulService class like this:

public class MyStatefulService : StatefulService, IDisposable
{
   public StatefulServiceBase(
     StatefulServiceContext serviceContext,
     IReliableStateManagerReplica2 reliableStateManagerReplica)
   : base(serviceContext, reliableStateManagerReplica)

   public void Dispose()
   {
       // my cleanup code
   }
}

I noticed that Service Fabric never calls Dispose() method in my class. Is there a different approach for disposing/cleaning up resources?

I have a services activated in shared process model. My service base class extends StatefulService class like this:

public class MyStatefulService : StatefulService, IDisposable
{
   public StatefulServiceBase(
     StatefulServiceContext serviceContext,
     IReliableStateManagerReplica2 reliableStateManagerReplica)
   : base(serviceContext, reliableStateManagerReplica)

   public void Dispose()
   {
       // my cleanup code
   }
}

I noticed that Service Fabric never calls Dispose() method in my class. Is there a different approach for disposing/cleaning up resources?

Share Improve this question edited yesterday Peter Bons 29.7k4 gold badges62 silver badges81 bronze badges Recognized by Microsoft Azure Collective asked yesterday Slobo80Slobo80 1888 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

There is no support for IDisposable, there is a ticket for it but it is still open.

You can override the StatefulServiceBase.OnCloseAsync() method and cleanup there or act on the cancellation request of the cancellation token passed to RunAsync().

The full lifecycle is documented here

本文标签: cBest way to clean up resources in StatefulServiceStack Overflow