Microsoft.Azure.WebJobs.Script.ScriptHost.Dispose C# (CSharp) Method

Dispose() protected method

protected Dispose ( bool disposing ) : void
disposing bool
return void
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                _scriptFileWatcher?.Dispose();
                _debugModeFileWatcher?.Dispose();

                foreach (var function in Functions)
                {
                    (function.Invoker as IDisposable)?.Dispose();
                }

                _blobLeaseManager?.Dispose();
                _restartEvent.Dispose();
                (TraceWriter as IDisposable)?.Dispose();

                NodeFunctionInvoker.UnhandledException -= OnUnhandledException;
            }
        }
    }

Usage Example

Esempio n. 1
0
        /// <summary>
        /// Remove the <see cref="ScriptHost"/> instance from the live instances collection,
        /// allowing it to finish currently executing functions before stopping and disposing of it.
        /// </summary>
        /// <param name="instance">The <see cref="ScriptHost"/> instance to remove</param>
        /// <param name="forceStop">Forces the call to stop and dispose of the instance, even if it isn't present in the live instances collection.</param>
        private async Task Orphan(ScriptHost instance, bool forceStop = false)
        {
            lock (_liveInstances)
            {
                bool removed = _liveInstances.Remove(instance);
                if (!forceStop && !removed)
                {
                    return; // somebody else is handling it
                }
            }

            try
            {
                // this thread now owns the instance
                if (instance.TraceWriter != null)
                {
                    instance.TraceWriter.Info("Stopping Host");
                }
                await instance.StopAsync();
            }
            finally
            {
                instance.Dispose();
            }
        }
All Usage Examples Of Microsoft.Azure.WebJobs.Script.ScriptHost::Dispose