コード例 #1
0
ファイル: RestClient.cs プロジェクト: wulouvre/PiWeb-Api
        private void RebuildHttpClient()
        {
            var timeout = _HttpClient.Timeout;

            _HttpClient?.Dispose();
            _WebRequestHandler?.Dispose();

            BuildHttpClient(timeout);
        }
コード例 #2
0
        public void ResetHandler()
        {
            if (requestHandler != null)
            {
                requestHandler.Dispose();
            }
            requestHandler = new WebRequestHandler
            {
                AutomaticDecompression = DecompressionMethods.GZip,
                AllowAutoRedirect      = false,
                UseDefaultCredentials  = false,
                UseCookies             = false
            };

            if (httpClient != null)
            {
                httpClient.Dispose();
            }

            httpClient = new HttpClient(requestHandler);
            httpClient.MaxResponseContentBufferSize = AppSettings.MaxResponseContentBufferSize;
            httpClient.Timeout = TimeSpan.FromSeconds(AppSettings.RequestTimeout);
            SetHttpRequestHeader("User-Agent", AppSettings.ClientUserAgentName);
            httpClient.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("Gzip"));
        }
コード例 #3
0
 private static async Task RunTaskAsync()
 {
     Trace.WriteLine("Start task", "ADBlocker");
     Trace.WriteLine($"Start Time: {DateTime.UtcNow.ToString("dd/MM/yyyy HH:mm:ss.fff")}", "ADBlocker");
     try
     {
         InitializeHttpClient();
         await RunBlockingTaskAsync();
         await RunScheduledTaskAsync();
         await UpdateTaskRuntimeAsync();
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
     finally
     {
         Trace.WriteLine($"End Time: {DateTime.UtcNow.ToString("dd/MM/yyyy HH:mm:ss.fff")}", "ADBlocker");
         Trace.WriteLine("End Task", "ADBlocker");
         Trace.WriteLine("");
         Trace.Close();
         _client?.Dispose();
         _handler?.Dispose();
     }
 }
コード例 #4
0
        public override void Dispose()
        {
            _requestHandler.Dispose();
            _httpClient.Dispose();
            _client.Dispose();

            base.Dispose();
        }
コード例 #5
0
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            if (_client != null)
            {
                _client.Dispose();
                _client = null;
            }

            if (_handler != null)
            {
                _handler.Dispose();
                _handler = null;
            }

            _disposed = true;
        }
コード例 #6
0
 private static async Task RunTaskAsync()
 {
     _logger.Info("Start Task");
     try
     {
         InitializeHttpClient();
         await RunBlockingTaskAsync();
         await RunScheduledTaskAsync();
         await UpdateTaskRuntimeAsync();
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
     finally
     {
         _logger.Info("End Task");
         _client?.Dispose();
         _handler?.Dispose();
     }
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: duquevieira/ADBlocker
        private static async Task RunTaskAsync()
        {
            Trace.WriteLine("Start task", "ADBlocker");
            Trace.WriteLine($"Start Time: {DateTime.UtcNow.ToString("dd/MM/yyyy HH:mm:ss.fff")}", "ADBlocker");
            InitializeHttpClient();
            try
            {
                var response = await _client.GetAsync("api/blockedloginrequests/config");

                response.EnsureSuccessStatusCode();
                var responseContent = await response.Content.ReadAsStringAsync();

                var taskConfig = JsonConvert.DeserializeObject <TaskConfiguration>(responseContent);
                if (taskConfig == null)
                {
                    return;
                }
                if (MustRunDailyTask(taskConfig))
                {
                    await RunDailyTaskAsync();
                }
                await RunScheduledTaskAsync();
                await UpdateTaskRuntimeAsync();
            }
            catch (Exception ex)
            {
                Trace.WriteLine("ERROR", "ADBlocker");
                ex.TraceError();
                RaygunClient.Send(ex);
            }
            finally
            {
                Trace.WriteLine($"End Time: {DateTime.UtcNow.ToString("dd/MM/yyyy HH:mm:ss.fff")}", "ADBlocker");
                Trace.WriteLine("End Task", "ADBlocker");
                Trace.WriteLine("");
                Trace.Close();
                _client?.Dispose();
                _handler?.Dispose();
            }
        }
コード例 #8
0
ファイル: ApmaxFixture.cs プロジェクト: retslig/ANDP
 public void TestCleanup()
 {
     _client.Dispose();
     _handler.Dispose();
 }
コード例 #9
0
 public void Dispose()
 {
     _serviceImpl.Dispose();
     _handler.Dispose();
 }
コード例 #10
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public override void Dispose()
 {
     _handler.Dispose();
     _client.Dispose();
 }