WhenAny InvalidOperationException

31 views
Skip to first unread message

Thomas Tomanek

unread,
Aug 22, 2012, 6:16:22 AM8/22/12
to reacti...@googlegroups.com
Hi,

I have the following simple code, however when the property change is raised the call to WhenAny throws an InvalidOperationException because 'the calling thread cannot access this object because a different thread owns it.'. Sure enough the code is executing on a worker thread. I can't see my code differs from any of the examples I've seen though.

        public ReactiveCommand OpenEditor { get; set; }

        private bool _EditorOpen;
        public bool EditorOpen
        {
            get { return _EditorOpen; }
            set { this.RaiseAndSetIfChanged(x => x.EditorOpen, value); }
        }

        public MainViewModel()
        {
            OpenEditor = new ReactiveCommand(this.WhenAny(x => x.EditorOpen, x => !x.Value));
            OpenEditor.Subscribe(x => DoSomething());
        }

        private void DoSomething()
        {
            EditorOpen = true;
        }

Cheers

Paul Betts

unread,
Aug 24, 2012, 3:21:32 PM8/24/12
to reacti...@googlegroups.com
Hi Thomas,

Is there any debug output in the debug window? You may have forgotten
to include a necessary reference.

--
Paul Betts <pa...@paulbetts.org>
Reply all
Reply to author
Forward
0 new messages