title: Observable events
body: <p>I have this code, original code <a href="https://social.msdn.microsoft.com/Forums/en-US/d459291a-4245-45ba-8888-35e07f7cf5b2/rx-sample-of-qbservable-provider-for-wmi-events-linq-to-wql?forum=rx" rel="nofollow">here</a>, and I need modify to insert output string in List of strings.</p>
  
  <p>How I do that?</p>
  
  <pre><code>    private static List&lt;string&gt; list_of_proc = new List&lt;string&gt;();
  
      static void Run&lt;T&gt;(Func&lt;IObservable&lt;T&gt;&gt; f, Action a)
      {
          Action&lt;string&gt; messageTarget = (x) =&gt; list_of_proc.Add(x);
          using (f().Subscribe(t =&gt; Console.WriteLine(t), p =&gt; messageTarget(p)))
          {
              Console.ReadLine();
              Console.WriteLine();
          }
      }
  </code></pre>
  
  <p>My action messageTarget don't compile.</p>
  
  <p>Out errors:<br></p>
  
  <pre>
  1>Program.cs(20,34,20,59): error CS1660: Cannot convert lambda expression to type 'System.IObserver' because it is not a delegate type
  1>Program.cs(20,61,20,82): error CS1593: Delegate 'System.Action' does not take 1 arguments
  1>Program.cs(20,61,20,82): error CS1660: Cannot convert lambda expression to type 'System.Threading.CancellationToken' because it is not a delegate type
  1>Program.cs(20,66,20,82): error CS1594: Delegate 'System.Action' has some invalid arguments
  1>Program.cs(20,80,20,81): error CS1503: Argument 1: cannot convert from 'System.Exception' to 'string'
  </pre>
  
  <p>This code compile fine with no errors:</p>
  
  <pre><code>        static void Run&lt;T&gt;(Func&lt;IObservable&lt;T&gt;&gt; f, Action a)
      {
          Action&lt;string&gt; messageTarget = (x) =&gt; list_of_proc.Add(x);
          using (f().Subscribe(t =&gt; Console.WriteLine(t)/*, p =&gt; messageTarget(p)*/))
          {
              Console.ReadLine();
              Console.WriteLine();
          }
      }
  </code></pre>
  
  <p>Subscribe has this form (System.Reactive.Core.dll, v2.2.5.0):<br></p>
  
  <pre>
  public static IDisposable Subscribe(this IObservable source, Action onNext);
  </pre>
  
  <p>This correct code:</p>
  
  <pre><code>    static void Run&lt;T&gt;(Func&lt;IObservable&lt;T&gt;&gt; f, Action a)
      {
          Action&lt;string&gt; messageTarget = (x) =&gt; list_of_proc.Add(x);
          using (f().Subscribe( t =&gt; messageTarget(t.ToString())))
          {
              Console.ReadLine();
              Console.WriteLine();
          }
      }
  </code></pre>