/// <summary>
        /// Stops all LiveServer's
        /// </summary>
        /// <returns></returns>
        public Task StopAsync()
        {
            return(AsyncAwaitor.AwaitAsync(nameof(LiveServerManager) + nameof(StopAsync), async() =>
            {
                // For each server
                foreach (var server in mLiveServers)
                {
                    // Stop server
                    await server.StopAsync();
                }

                // Clear list
                mLiveServers.Clear();
            }));
        }
Пример #2
0
        /// <summary>
        /// Stop listening
        /// </summary>
        public async Task StopAsync()
        {
            // Log it
            CoreLogger.Log($"LiveServer '{ServingDirectory}' stopping...", type: LogType.Warning);

            // Lock call
            await AsyncAwaitor.AwaitAsync(mStopLock, async() =>
            {
                try
                {
                    // Stop listener
                    mListener.Stop();
                }
                catch (Exception ex)
                {
                    // Log it
                    Debugger.Break();
                    CoreLogger.Log($"Failed to stop LiveServer listener. {ex.Message}", type: LogType.Warning);
                }

                // Set stopping flag to true
                Stopping = true;

                // Dispose folder watcher
                mFolderWatcher?.Dispose();
                mFolderWatcher = null;

                // Set it so any blocked calls pass on
                mContentChangedResetEvent.Set();
                mContentChangedResetEvent.Reset();

                // Flag that we are no longer listening
                while (Listening)
                {
                    await Task.Delay(100);
                }

                // Log it
                CoreLogger.Log($"LiveServer {ServingDirectory} stopped", type: LogType.Attention);
            });
        }