title: Autofac Owned<>
body: <p>I don't quite understand the difference between Autofac Owned and not Owned disposable components.</p>
  
  <pre><code>interface IMessageHandler
  {
    void Handle(Message message);
  }
  
  class MessagePump
  {
    Func&lt;Owned&lt;IMessageHandler&gt;&gt; _handlerFactory;
  
    public MessagePump(Func&lt;Owned&lt;IMessageHandler&gt;&gt; handlerFactory)
    {
      _handlerFactory = handlerFactory;
    }
  
    public void Go()
    {
      while(true)
      {
        var message = NextMessage();
  
        using (var handler = _handlerFactory())
        {
          handler.Value.Handle(message);
        }
      }
    }
  }
  </code></pre>
  
  <p>What would be difference between the above code to the following:</p>
  
  <pre><code> interface IMessageHandler
      {
        void Handle(Message message);
      }
  
      class MessagePump
      {
        Func&lt;Owned&lt;IMessageHandler&gt;&gt; _handlerFactory;
  
        public MessagePump(Func&lt;IMessageHandler&gt; handlerFactory)
        {
          _handlerFactory = handlerFactory;
        }
  
        public void Go()
        {
          while(true)
          {
            var message = NextMessage();
  
            using (var handler = _handlerFactory())
            {
              handler.Handle(message);
            }
          }
        }
      }
  </code></pre>
  
  <p>They are both disposed manually when I choose, what is the difference than?</p>