title: How to use Task.Run(Action<T>)
body: <p>I am attempting to create a method that accepts TcpClient connections and performs a task once a client is connected, "ConnectedAction". I am receiving a compile error when trying to have a new task created to run the delegate "ConnectedAction".</p>
  
  <blockquote>
    <p>Argument 1: cannot convert from 'void' to 'System.Func'</p>
  </blockquote>
  
  <p>I believe that this error is because the method is trying to run the "ConnectedAction" method and return void to the Task.Run parameter.</p>
  
  <p>How do I have the Task run the "ConnectedAction" delegate?  </p>
  
  <pre><code>class Listener
  {
      public IPEndPoint ListenerEndPoint {get; private set;}
      public int TotalAttemptedConnections { get; private set; }
      public Action&lt;TcpClient&gt; ConnectedAction { get; private set; }
  
      public Listener(IPEndPoint listenerEndPoint, Action&lt;TcpClient&gt; connectedAction)
      {
          ConnectedAction = connectedAction;
          ListenerEndPoint = listenerEndPoint;
  
          Task.Factory.StartNew(Listen, TaskCreationOptions.LongRunning);
      }
  
      private void Listen()
      {
          TcpListener tcpListener = new TcpListener(ListenerEndPoint);
          tcpListener.Start();
  
          while (true)
          {
              TcpClient tcpClient = tcpListener.AcceptTcpClient();
              TotalAttemptedConnections++;
  
              //Error here 
              Task.Run(ConnectedAction(tcpClient));
          }
      }
  }
  </code></pre>