/// <summary>
        /// This is the main entry point for your service instance.
        /// </summary>
        /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service instance.</param>
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            // setup the metrics and start the metrics builder on a 5 second interval
            var metricsBuilder = new MetricsBuilder();

            metricsBuilder.Add(new CPUMetric());
            metricsBuilder.Add(new WorkingSetMetric());
            metricsBuilder.Add(new IterationsCountMetric(this));
            metricsBuilder.Start(this.Partition, new TimeSpan(0, 0, 5));

            try
            {
                while (true)
                {
                    cancellationToken.ThrowIfCancellationRequested();

                    ServiceEventSource.Current.ServiceMessage(this.Context, "Working-{0}", ++_iterations);

                    await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
                }
            }
            catch (Exception)
            {
                metricsBuilder.Stop();
            }
        }