Pouria Sharif Pouria Sharif - 1 year ago 83
C# Question

How can I fire event for system variables?

I am trying to make event that fire when


Answer Source

Here is how to do this very simply with Rx. First, NuGet "System.Reactive.Windows.Forms", and then you can do this:

IDisposable subscription =
        .Select(n => Application.OpenForms.Count)
        .Subscribe(count =>
            /* Changed so do something here */

This is obviously a polling-based solution so you need to choose an appropriate TimeSpan for your needs.

To stop the subscription, when closing down your application, you just call subscription.Dispose();.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download