title: Does Func<T> callbacks can cause memory leak?
body: <p>Everybody know that eventhandlers that are never removed for the invocationList can cause memory leak in C#. 
  My questions is, Can we have memory leak if we use Func as callback? (therefore supporting only one subscriber)</p>
  
  <p>Take the following example (copy and paste into console application):</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          var m = new Manager();
  
          var c1 = new Channel();
          m.Add(c1);
          Console.WriteLine("m = {0}",GC.GetTotalMemory(true));
  
          Console.ReadLine();
  
          m.Remove(c1);
          Console.WriteLine("m = {0}", GC.GetTotalMemory(true));
  
          Console.ReadLine();
      }
  }
  
  public class Manager
  {
  
      List&lt;Channel&gt; channels = new List&lt;Channel&gt;();
  
      public void Add(Channel c)
      {
  
          channels.Add(c);
  
          c.OnTick = OnTick;
  
          c.Start();
      }
  
      public void Remove(Channel c)
      {
          channels.Remove(c);
          //do we have a memory leak at this point?
          //does c1 still pointing to Manager func and cannot be GCed?
          c.Stop();
      }
  
      private Task OnTick(int i)
      {
          Console.WriteLine(i);
          return Task.FromResult(0);
      }
  }
  
  public class Channel
  {
      public Func&lt;int, Task&gt; OnTick;
      Random r = new Random();
      private System.Timers.Timer aTimer;
      public Channel()
      {
          OnTick = i =&gt; Task.FromResult(r.Next());
      }
  
      public void Start()
      {
          aTimer = new System.Timers.Timer(1000);
  
          aTimer.Elapsed += (sender, args) =&gt; OnTick(r.Next());
  
          // Have the timer fire repeated events (true is the default)
          aTimer.AutoReset = true;
  
          // Start the timer
          aTimer.Enabled = true;
      }
  
      public void Stop()
      {
          aTimer.Dispose();
      }
  }
  </code></pre>