.NET Fiddle

CSharp · Console

/Program.cs

using System;
using System.Net.Http;

public class Program
{
  	private static T CallInItsOwnScope<T>(Func<T> getter)
	{
		return getter();
	}

	public static void Main()
	{
		var client = new HttpClient();
		var wRef2 = CallInItsOwnScope(() =>
									  {
										  using (var response = client.GetAsync(new Uri("https://postman-echo.com/get?foo1=bar1&foo2=bar2")).Result)
										  {
											  return new WeakReference(response);
										  }
									  });
		GC.Collect();
		GC.WaitForPendingFinalizers();
		Console.WriteLine("Alive: " + wRef2.IsAlive);

		client.Dispose();

		GC.Collect();
		GC.WaitForPendingFinalizers();
		Console.WriteLine("Alive: " + wRef2.IsAlive);
	}
}
;