Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Let's take a look at the code you have.</p> <pre><code>var observable = Observable.FromEventPattern&lt;BasicDeliverEventHandler&gt;( handler =&gt; _innerConsumer.Received += OnReceived, handler =&gt; _innerConsumer.Received -= OnReceived ); var timeout = observable.Timeout(TimeSpan.FromSeconds(20)); using (timeout.Subscribe( _ =&gt; { }, exception =&gt; Tracer.Warning("Eventing Consumer timeout : {0}", exception.Message))) { } </code></pre> <p>We can re-write the subscription logic like so:</p> <pre><code>var subscription = timeout.Subscribe( _ =&gt; { } exception =&gt; Tracer.Warning("Eventing Consumer timeout : {0}", exception.Message) ); subscription.Dispose(); // This is bad </code></pre> <p>Since your subscription is being disposed of immediately, your observer isn't receiving an of the notifications you're expecting.</p> <p>By removing <code>subscription.Dispose()</code>, or the <code>using</code> statement, your observer should receive a <code>TimeoutException</code> 20 seconds after subscribing. However, because <code>Exception</code>s also cancel subscriptions, you will only ever receive this <code>Exception</code> once.</p> <p>Furthermore, the <code>Timeout</code> operator starts a timeout at the time of subscription, and does not cancel the timeout unless the subscription is cancelled, or the source observer completes.</p> <p>You might want to try using a different operator, such as <code>Throttle</code>.</p> <pre><code>observable.Throttle(TimeSpan.FromSeconds(20)) .Subscribe(x =&gt; Console.WriteLine("it has been 20 seconds since we received the last notification.") ) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload