I have the following code that uses the Observable class from System.Reactive. I'm using the November 2009 Silverlight 3 toolkit.
private IObservable<Event<EventArgs>> _ob;
private IDisposable _proxy;
...
private void Init()
{
_ob = Observable
.FromEvent<EventArgs>( x_Grid, "LayoutUpdated" )
.Throttle( 2000 ); // *** <- The problem
_proxy = _ob.Subscribe( () => { } );
}
The code snippet results in the exception:
System.ObjectDisposedException: Cannot access a disposed object.
at System.Threading.TimerBase.ChangeTimer(UInt32 dueTime, UInt32 period)
at System.Threading.Timer.Change(Int32 dueTime, Int32 period)
at System.Linq.Observable.<>c__DisplayClass175`2.<>c__DisplayClass17a.<Generate>b__173(Object _)
at System.Threading._TimerCallback.TimerCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading._TimerCallback.PerformTimerCallback(Object state)
If the Throttle() method is not present, the code works fine. The exception stack trace indicates accessing a disposed object. The only disposable object I am aware of is the one returned by the Subscribe() call: but this has not been disposed.
Can someone point to the problem with this code.