Skip to content

Instantly share code, notes, and snippets.

@ritalin
Created February 15, 2012 18:21
Show Gist options
  • Save ritalin/1837950 to your computer and use it in GitHub Desktop.
Save ritalin/1837950 to your computer and use it in GitHub Desktop.
Delay Test on Reactive mono
// Mono JIT compiler version 2.10.6 (tarball Fri Sep 16 00:13:06 EDT 2011)
// Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
// TLS: normal
// SIGSEGV: normal
// Notification: kqueue
// Architecture: x86
// Disabled: none
// Misc: debugger softdebug
// LLVM: yes(2.9svn-mono)
// GC: Included Boehm (with typed GC)
using System;
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using System.Threading;
namespace Sample {
static class Program {
static IObservable<T> PseudoAsync<T>(T inValue, int inDelay) {
return Observable
.Return(inValue)
.Delay(TimeSpan.FromSeconds(inDelay))
;
}
static void Main(string[] args) {
Enumerable
.Range(1, 5)
.ToObservable()
.SelectMany(n => PseudoAsync(n, 1))
.Subscribe(n => Console.Write(string.Format("{0} -> ", n)))
;
Thread.Sleep(0);
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment