Silverlight 4 accessing WCF Data Services: BeginInvoke frustrations.

Posted by Gatmando on Stack Overflow See other posts from Stack Overflow or by Gatmando
Published on 2010-04-04T01:05:45Z Indexed on 2010/04/04 1:13 UTC
Read the original article Hit count: 452

Filed under:
|
|
|
|

Hi,

I'm attempting to follow a pattern for performing WCF data service queries using the Silverlight 4 beta. The following is my code:

    public CodeTables()
    {
        CodeCountries = new ObservableCollection<dsRealHomes.CodeCountries>();

        dsRealHomes.RealHomesEntities myClient = null;
        myClient = staticGlobals.RealHomesContext();

        object userState = null;


        myClient.BeginExecute<dsRealHomes.CodeCountries>(new Uri("CodeCountries"),
        (IAsyncResult asyncResult) =>
        {
            Dispatcher.BeginInvoke(
                 () =>
                 {
                     var test = myClient.EndExecute<dsRealHomes.CodeCountries>asyncResult).ToList();
                 }
             );
        }, userState);
    }

This is derived from a number of examples I've come across for WCF data services with silverlight. Unfortunately no matter how I try to implement the code i end up with the following error on 'Dispatcher.BeginInvoke':

'An object reference is required for the non-static field, method, or property (System.Windows.Threading.Dispatcher.BeginInvoke(System.Action)'

Thanks

© Stack Overflow or respective owner

Related posts about wcf

Related posts about data