Kudu.Core.Jobs.ContinuousJobRunner.StopJob C# (CSharp) Method

StopJob() public method

public StopJob ( bool isShutdown = false ) : void
isShutdown bool
return void
        public void StopJob(bool isShutdown = false)
        {
            Interlocked.Exchange(ref _started, 0);

            bool logStopped = false;

            if (_continuousJobThread != null)
            {
                logStopped = true;

                if (isShutdown)
                {
                    LogInformation("WebJob is stopping due to website shutting down");
                }

                _continuousJobLogger.ReportStatus(ContinuousJobStatus.Stopping);

                NotifyShutdownJob();

                // By default give the continuous job 5 seconds before killing it (after notifying the continuous job)
                if (!_continuousJobThread.Join(JobSettings.GetStoppingWaitTime(DefaultContinuousJobStoppingWaitTimeInSeconds)))
                {
                    _continuousJobThread.KuduAbort(String.Format("Stopping {0} {1} job", JobName, Constants.ContinuousPath));
                }

                _continuousJobThread = null;
            }

            SafeKillAllRunningJobInstances(_continuousJobLogger);

            if (logStopped)
            {
                UpdateStatusIfChanged(ContinuousJobStatus.Stopped);
            }
        }