Dispose() защищенный Метод

protected Dispose ( bool disposing ) : void
disposing bool
Результат void
Пример #1
0
        protected override void Dispose(bool disposing)
        {
            if (disposing && !_disposed)
            {
                _disposed = true;
                if (_winHttpHandler != null)
                {
                    _winHttpHandler.Dispose();
                }
                else
                {
                    _managedHandler.Dispose();
                }
            }

            base.Dispose(disposing);
        }
Пример #2
0
 public void SendAsync_MultipleCallsWithDispose_NoHandleLeaksManuallyVerifiedUsingLogging()
 {
     WinHttpHandler handler;
     HttpResponseMessage response;
     for (int i = 0; i < 50; i++)
     {
         handler = new WinHttpHandler();
         response = SendRequestHelper.Send(handler, () => { });
         response.Dispose();
         handler.Dispose();
     }
 }
Пример #3
0
 public void SendAsync_MultipleCallsWithDispose_NoHandleLeaks()
 {
     WinHttpHandler handler;
     HttpResponseMessage response;
     for (int i = 0; i < 50; i++)
     {
         handler = new WinHttpHandler();
         response = SendRequestHelper(handler, () => { });
         response.Dispose();
         handler.Dispose();
     }
     
     FakeSafeWinHttpHandle.ForceGarbageCollection();
     
     Assert.Equal(0, FakeSafeWinHttpHandle.HandlesOpen);
 }