At.FF.Krems.FullscreenBrowser.HttpServer.Initialize C# (CSharp) Method

Initialize() private method

Initializes this instance.
private Initialize ( bool force = false ) : void
force bool Force initialization, even if already initialized.
return void
        private void Initialize(bool force = false)
        {
            if (this.initializeCalled && !force)
            {
                return;
            }

            this.initializeCalled = true;
            this.cancellationTokenSource?.Cancel();

            this.cancellationTokenSource = new CancellationTokenSource();
            this.listener?.Stop();

            var token = this.cancellationTokenSource.Token;
            this.listenTask = Task.Factory.StartNew(
                    () => this.Listen(token),
                    token,
                    TaskCreationOptions.LongRunning,
                    TaskScheduler.Default);
        }