rehansaeed.github.io icon indicating copy to clipboard operation
rehansaeed.github.io copied to clipboard

[Comment] Reactive Extensions (Rx) - Part 4 - Replacing Timers

Open RehanSaeed opened this issue 5 years ago • 3 comments

https://rehansaeed.com/reactive-extensions-part4-replacing-timers/

RehanSaeed avatar May 12 '20 11:05 RehanSaeed

Michael Khalsa Michael Khalsa commented on 2018-04-19 01:33:58

Nice series, thanks!

Question about the timer example: Is it best practice to add on .Dispose to the subscriber to have it cleanup (assuming yes), or will this happen automatically when the method completes. (showed example in vb)

Observable
    .Timer(TimeSpan.FromMilliseconds(intervalMs))
    .ObserveOn(Threading.SynchronizationContext.Current)
    .Subscribe(Function(x) StatusBar.Panels("statusPanelHeartbeat").Visible = False,
               Function(x) StatusBar.Panels("statusPanelHeartbeat").Visible = False)
    .Dispose()

RehanSaeed avatar May 12 '20 11:05 RehanSaeed

Muhammad Rehan Saeed Muhammad Rehan Saeed commented on 2018-04-19 09:16:59

Nice series, thanks!

Question about the timer example: Is it best practice to add on .Dispose to the subscriber to have it cleanup (assuming yes), or will this happen automatically when the method completes. (showed example in vb)

Observable
    .Timer(TimeSpan.FromMilliseconds(intervalMs))
    .ObserveOn(Threading.SynchronizationContext.Current)
    .Subscribe(Function(x) StatusBar.Panels("statusPanelHeartbeat").Visible = False,
               Function(x) StatusBar.Panels("statusPanelHeartbeat").Visible = False)
    .Dispose()

Here is a really good explanation:

https://stackoverflow.com/questions/7703366/reactive-observable-subscription-disposal

RehanSaeed avatar May 12 '20 11:05 RehanSaeed

Michael Khalsa Michael Khalsa commented on 2018-04-22 00:29:47

Here is a really good explanation:

https://stackoverflow.com/questions/7703366/reactive-observable-subscription-disposal

Thank you.

It was necessary to remove the .Dispose in this case to make it work correctly.

RehanSaeed avatar May 12 '20 11:05 RehanSaeed