System.Reactive.Windows.Forms 7.0.0-preview.20
Windows Forms support for Rx (Reactive Extensions for .NET)
This is part of the Reactive Extensions for .NET (Rx). Rx enables event-driven programming with a composable, declarative model. The main Rx package is System.Reactive, which provides the core types and operators. This package, System.Reactive.Windows.Forms, provides additional support for using Rx with Windows Forms applications.
If you had been using the Windows Forms support in earlier versions of Rx (pre v7), you'll know that all UI-framework-specific functionality used to live in the main System.Reactive package. See ADR 0005 (Moving UI framework support out of System.Reactive) for an in depth explanation of the reason for moving these features out into separate packages.
Getting started
Run the following at a command line:
mkdir TryRxWinforms
cd TryRxWinforms
dotnet new winforms
dotnet add package System.Reactive.Windows.Forms
Alternatively, if you have Visual Studio installed, create a new .NET Windows Forms project, and then use the NuGet package manager to add a reference to System.Reactive.Windows.Forms.
You can then add the following code to your Form1.cs. First, add this using directive at the top of the file:
using System.Reactive.Linq;
Then inside the constructor, after the call to InitializeComponent() add this:
IObservable<long> ticks = Observable.Timer(
dueTime: TimeSpan.Zero,
period: TimeSpan.FromSeconds(1));
ticks
.ObserveOn(this)
.Subscribe(tick => this.Text = $"Tick {tick}");
This creates an observable source (ticks) that produces an event once every second. It adds a handler to that source that updates the main window's title bar text. By default, an Observable.Timer created in this way will raise events on a thread pool thread, which would result in an exception when trying to set the window title bar. This example avoids that problem by calling ObserveOn(this). This invokes an overload of ObserveOn that is specific to the System.Reactive.Windows.Forms library. It declares that we want a wrapper around the ticks observable that will raise notifications through the event loop for the Control passed to ObserveOn. So when the handler specified in Subscribe executes, it does so on the UI thread, meaning it is able to update the window title successfully.
Feedback
You can create issues at the https://github.com/dotnet/reactive repository
Showing the top 20 packages that depend on System.Reactive.Windows.Forms.
| Packages | Downloads |
|---|---|
|
System.Reactive.Compatibility
Reactive Extensions (Rx) Compatibility Library for enabling v3 apps to work with v4
|
28 |
|
System.Reactive.Compatibility
Reactive Extensions (Rx) Compatibility Library for enabling v3 apps to work with v4
|
24 |
|
System.Reactive.Compatibility
Reactive Extensions (Rx) Compatibility Library for enabling v3 apps to work with v4
|
23 |
|
System.Reactive.Compatibility
Reactive Extensions (Rx) Compatibility Library for enabling v3 apps to work with v4
|
22 |
|
System.Reactive.Compatibility
Reactive Extensions (Rx) Compatibility Library for enabling v3 apps to work with v4
|
21 |
.NET Framework 4.7.2
- System.Reactive (>= 7.0.0-preview.20)
- System.Threading.Tasks.Extensions (>= 4.6.3)
.NET 8.0
- System.Reactive (>= 7.0.0-preview.20)
| Version | Downloads | Last updated |
|---|---|---|
| 7.0.0-rc.1 | 5 | 06/20/2026 |
| 7.0.0-preview.20 | 5 | 06/04/2026 |
| 7.0.0-preview.16 | 7 | 05/27/2026 |
| 7.0.0-preview.15 | 9 | 05/24/2026 |
| 7.0.0-preview.1 | 22 | 03/28/2026 |
| 6.1.0 | 17 | 03/29/2026 |
| 6.1.0-preview.9 | 20 | 03/28/2026 |
| 6.0.2 | 18 | 03/29/2026 |
| 6.0.1 | 18 | 03/29/2026 |
| 6.0.1-preview.1 | 22 | 03/29/2026 |
| 6.0.0 | 18 | 03/29/2026 |
| 6.0.0-preview.16 | 17 | 03/28/2026 |
| 6.0.0-preview.13 | 22 | 03/29/2026 |
| 6.0.0-preview.9 | 20 | 03/29/2026 |
| 6.0.0-preview.1 | 19 | 03/29/2026 |
| 5.0.0 | 18 | 03/29/2026 |
| 5.0.0-preview.220 | 21 | 03/29/2026 |
| 5.0.0-preview.16 | 19 | 03/29/2026 |
| 4.4.1 | 17 | 03/28/2026 |
| 4.3.2 | 17 | 03/29/2026 |
| 4.3.1 | 18 | 03/29/2026 |
| 4.2.2 | 17 | 03/29/2026 |
| 4.2.0 | 19 | 03/29/2026 |
| 4.2.0-preview.625 | 18 | 03/29/2026 |
| 4.2.0-preview.566 | 18 | 03/29/2026 |
| 4.2.0-preview.102 | 18 | 03/29/2026 |
| 4.2.0-preview.63 | 17 | 03/29/2026 |
| 4.1.6 | 19 | 03/29/2026 |
| 4.1.5 | 18 | 03/28/2026 |
| 4.1.4 | 20 | 03/29/2026 |
| 4.1.3 | 18 | 03/29/2026 |
| 4.1.2 | 17 | 03/29/2026 |
| 4.1.1 | 16 | 03/29/2026 |
| 4.1.0 | 21 | 03/29/2026 |
| 4.1.0-preview.330 | 18 | 03/29/2026 |
| 4.1.0-preview.84 | 20 | 03/28/2026 |
| 4.0.0 | 21 | 03/29/2026 |
| 4.0.0-preview.4.build.391 | 18 | 03/29/2026 |
| 4.0.0-preview.3.build.380 | 19 | 03/29/2026 |
| 4.0.0-preview.2.build.379 | 16 | 03/29/2026 |
| 3.1.1 | 16 | 03/29/2026 |
| 3.1.0 | 15 | 03/29/2026 |
| 3.1.0-rc | 16 | 03/29/2026 |
| 3.0.0 | 20 | 03/28/2026 |