title: How to use .NET Action to execute a method with unknown number of parameters?
body: <p>I want to execute some operations on a worker thread while displaying a progress bar to the user. I've created a class </p>
  
  <pre><code>public class ProgressBar
  {
     public void StartAsyncTask(Action action)
     {
        Task t = new Task(action);
        t.start();
     }
  }
  </code></pre>
  
  <p>I found out that I can send any method to the <code>StartAsyncTask</code> in the following way:</p>
  
  <pre><code>  ProgressBar pb = new ProgressBar();
    pb.StartAsyncTask( () =&gt; DoSomething(15, "something"));
  
    public void DoSomething(int i, string s)
     {
        //do something
     }
  </code></pre>
  
  <p>First of all, I can't seem to understand what is and how is lambda expression - <code>() =&gt;</code> - translated and how is the <code>Action</code> object passed a delegate with an unknown number of parameters. </p>
  
  <p>I would like to use a <code>BackgroundWorker</code> with my ProgressBar but in this case I would need to invoke the action. So something like this:</p>
  
  <pre><code>void m_backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
  {
      Action action = e.Argument as Action; //same action here passed through EventArgs
     //but already in a worker thread so no need for the Task object 
  
     //and now i need to somehow invoke the action object but i don't know what the parameters are. 
  
     action.Invoke( ? ); 
  }
  </code></pre>
  
  <p>How is it possible in the first example to execute the action without knowing the parameters in <code>StartAsyncTask(Action action)</code> method?</p>
  
  <p>Why do I need to know the parameters when invoking the action in this case? </p>
  
  <p>Everything about how/why/when to use "<code>Action</code>" is pretty unclear to me even if I read MSDN documentation and some other threads here. 
  Any information on this will help me.</p>