title: C# equivalent to C++ Functor (as a break condition)
body: <p>I have the following example code:</p>
  <pre><code>void Foo()
  {   
      while (!_cancelSrc.Token.IsCancellationRequested &amp;&amp; currTryNum &lt; maxRetryTimes &amp;&amp; !isPublished)
      {
          // do something 
      }
  }
  </code></pre>
  <p>I want to change the while condition, and pass Foo something equivalent to C++ Functor, that will hold an internal state in order to keep track of currTryNum and isPublish variables. I will define in each what is the maxRetryTimes. something like this:</p>
  <pre><code>while (!_cancelSrc.Token.IsCancellationRequested &amp;&amp; isRequireToContinue())
  {
      // do something 
  }
  </code></pre>
  <p>P.S. It is important to also allow some functor that always returns true, in case I want the while to always run.
  tnx!</p>