private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { // TODO: dispose managed state (managed objects). if (httpClient != null) { httpClient.Dispose(); httpClient = null; } if (httpClientHandler != null) { httpClientHandler.Dispose(); httpClientHandler = null; } if (Options != null) { Options = null; } RemoveAllExtractors(); } // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. // TODO: set large fields to null. //MethodInfo i = this.GetType().GetMethod("DisposePython", BindingFlags.NonPublic | BindingFlags.Instance); //if (i != null) i.Invoke(this, new object[] { disposing }); disposedValue = true; } }
public void SetupHttpClient() { httpClientHandler = new YTDL_HttpClientHandler { CookieContainer = new CookieContainer(), AllowAutoRedirect = true, }; httpClient = new HttpClient(httpClientHandler, true); }