System.Net.HttpListener.BeginGetContext C# (CSharp) Method

BeginGetContext() public method

public BeginGetContext ( AsyncCallback callback, object state ) : IAsyncResult
callback AsyncCallback
state object
return IAsyncResult
        public IAsyncResult BeginGetContext(AsyncCallback callback, object state)
        {
            throw new PlatformNotSupportedException();
        }

Usage Example

Esempio n. 1
0
        public void Start(string bindUrl)
        {
            Ensure.NotNull(bindUrl, nameof(bindUrl));

            _httpListener = new HttpListener { IgnoreWriteExceptions = false };
            _httpListener.Prefixes.Add(bindUrl);
            _httpListener.Start();


            AsyncCallback acceptConnection = null;
            acceptConnection = state =>
            {
                try
                {
                    HttpListenerContext clientContext = _httpListener.EndGetContext(state);
                    Log.Info($"New Ecr connection from: {clientContext.Request.RemoteEndPoint}");

                    ProcessAsync(clientContext);
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                }
                finally
                {
                    _httpListener.BeginGetContext(acceptConnection, null);
                }
            };

            _httpListener.BeginGetContext(acceptConnection, null);

            RegisterActions();
        }
All Usage Examples Of System.Net.HttpListener::BeginGetContext