public async Task CloseAsync(PartitionContext context, CloseReason reason) { if (OnMessageReceived != null) { foreach (EventHandler<MessageReceivedEventArgs> subscriber in OnMessageReceived.GetInvocationList()) { OnMessageReceived -= subscriber; } } this.checkpointStopWatch.Stop(); if (reason.Equals(CloseReason.Shutdown)) { await context.CheckpointAsync(); } }