Using Rx to execute delayed action once with cancellation for each window
specifically I am trying to simulate performing an action if the key is held down for a duration greater than Threshold (T). 

I am trying to do this using Reactive Extensions .NET (The stable 1.0 version) **without state variables.**

Here's the marble diagram of my inputs and what I need: 

let T = 3 (so 4 dddd without a key up event make up a "key held down")

keyDown: --dddd---dd--d-dddddddddd----

keyUp:   -----------u-----u--u---------------u--

desired: --------a---------------a----------

Here's some code I have to get you started, it doesn't work because it produces "a"s for every d after d > T.

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            var keyDownStream = Observable.FromEventPattern<KeyEventArgs>(this, "KeyDown").Where(args => args.EventArgs.Key == Key.OemPeriod);
            var keyUpStream = Observable.FromEventPattern<KeyEventArgs>(this, "KeyUp").Where(args => args.EventArgs.Key == Key.OemPeriod);

            keyDownStream
                .DelayOrCancel(TimeSpan.FromSeconds(2), keyUpStream)
                .Subscribe(result =>
                  {
                      Console.WriteLine("KeyHold");
                      //do stuff 
                  });
        }
    }

    public static class JustinsRx
    {
        public static IObservable<T> DelayOrCancel<T, TCancel>(this IObservable<T> source,
                                         TimeSpan delay,
                                         IObservable<TCancel> cancel)
        {
            //argument checking skipped
            return from s in source
                   from i in Observable.Timer(delay).TakeUntil(cancel)
                   select s;
        }
    }
Using Rx to execute delayed action once with cancellation for each window
===

specifically I am trying to simulate performing an action if the key is held down for a duration greater than Threshold (T). 

I am trying to do this using Reactive Extensions .NET (The stable 1.0 version) **without state variables.**

Here's the marble diagram of my inputs and what I need: 

let T = 3 (so 4 dddd without a key up event make up a "key held down")

keyDown: --dddd---dd--d-dddddddddd----

keyUp:   -----------u-----u--u---------------u--

desired: --------a---------------a----------

Here's some code I have to get you started, it doesn't work because it produces "a"s for every d after d > T.

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            var keyDownStream = Observable.FromEventPattern<KeyEventArgs>(this, "KeyDown").Where(args => args.EventArgs.Key == Key.OemPeriod);
            var keyUpStream = Observable.FromEventPattern<KeyEventArgs>(this, "KeyUp").Where(args => args.EventArgs.Key == Key.OemPeriod);

            keyDownStream
                .DelayOrCancel(TimeSpan.FromSeconds(2), keyUpStream)
                .Subscribe(result =>
                  {
                      Console.WriteLine("KeyHold");
                      //do stuff 
                  });
        }
    }

    public static class JustinsRx
    {
        public static IObservable<T> DelayOrCancel<T, TCancel>(this IObservable<T> source,
                                         TimeSpan delay,
                                         IObservable<TCancel> cancel)
        {
            //argument checking skipped
            return from s in source
                   from i in Observable.Timer(delay).TakeUntil(cancel)
                   select s;
        }
    }