WCF Service Method always Async

85 Views Asked by At

I have a problem with calling a method from my DataService in my ViewModel. The problem is, that every method I create in my DataServicd- Implementation gets Async in my ViewModel, so i can not get any data from it. I am not so familiar with WCF so I am not able to solve the problem at my own.

This is the DataService-Interface:

[ServiceContract]
public interface IDataService
{

    [OperationContract]
    ObservableCollection<object> GetStartPageKPIObjects();

    [OperationContract]
    Object DoSomething();
}

This is my DataService Implementation

public class DataService : IDataService
{
    public ObservableCollection<object> GetStartPageKPIObjects()
    {
        ObservableCollection<object> tempItems = new ObservableCollection<object>();

        .........tempItems.add(...)
        .........tempItems.add(...)

        return tempItems;
    }




    public object DoSomething()
    {
        return new Object();
    }
}

This is how I get the Object Reference to the DataService:

******.ServiceReference.DataServiceClient dataClient = new ******.ServiceReference.DataServiceClient();

Now, I would like to access the data from my Service:

dataClient.GetStartPageKPIObjectsAsync();
dataClient.DoSomethingAsync();

But both return (awaitable) Task<object>! How do I now get the Data from the Service?

1

There are 1 best solutions below

4
On

There are non-async methods as well, maybe you didn't see them. You can turn off generation of async methods in the service ref settings. Then they disappear completely.