Network Status Observer

Mar 9, 2012 at 11:17 PM

I am trying to implement the network status observer as outlined elsewhere, using the INetworkService interface and an observer as per the code below:

        private readonly INetworkService networkService;
        private IDisposable networkStatusObserver;
            this.networkStatusObserver = this.networkService.Status()
                 .ObserveOnDispatcher()
                 .Subscribe(networkType => this.NetworkStatus = networkType);

 

My project has got references to Microsoft.Phone.Reactive and also System.Observable, but I am getting the following error when trying to compile:

Error 2 The call is ambiguous between the following methods or properties: 'Microsoft.Phone.Reactive.ObservableExtensions.Subscribe<WP7Contrib.Communications.NetworkType>(System.IObservable<WP7Contrib.Communications.NetworkType>, System.Action<WP7Contrib.Communications.NetworkType>)' and 'System.ObservableExtensions.Subscribe<WP7Contrib.Communications.NetworkType>(System.IObservable<WP7Contrib.Communications.NetworkType>, System.Action<WP7Contrib.Communications.NetworkType>)'

If I remove references to either of the libraries mentioned other stuff will not compile, has anyone got any pointers/ideas how I could overcome this?  

Been banging my head against a wall for a while on this one.

Cheers,
Rupert.

Mar 15, 2012 at 10:38 PM

Remove the reference to Microsoft.Phone.Reactive - this is no longer supported by MS (big issue found with memory I believe)

Make sure you have references to:

System.Reactive,

System.Reactive.Windows.Threading

 

Mar 16, 2012 at 6:34 PM

That's great thanks.

Just need to add the System.Reactive.Linq namespace to the class to get the ObserveOnDispatcher to be resolved and now it all compiles.