Implementing an interface using an asynchronous WCF service?

Posted by John K. on Stack Overflow See other posts from Stack Overflow or by John K.
Published on 2010-04-14T17:11:59Z Indexed on 2010/04/14 17:43 UTC
Read the original article Hit count: 320

Filed under:
|
|

Hello,

I am trying to figure out if it is possible to implement a .NET interface, where the interface method has to return something and you are implementing that particular interface method with an asynchronous WCF service?

Hopefully you should already see the issue I am encountering.

Here is the interface:

    public interface IDataService
    {
        IDataServiceResponse SendDataRequest();
    }

IDataServiceResponse is supposed to represent a simple container that holds the result of my asynchronous WCF callback.

Here is the code snippet where I am implementing the interface method, SendDataRequest()

        public IDataServiceResponse SendDataRequest()
        {
            InitializeDataServiceParameters();

            // Call the web service asynchronously, here....
            _client.BeginQueryJobs(_parameters, DataServiceQueryCallBack,  _client);

            // How do I return _dataServiceResponse, if I am calling the WCF service
            // asynchronously??

            return _dataServiceResponse;
        }

And the callback method signature:

void DataServiceQueryCallBack(IAsyncResult result)
{
  // ... implementation code
}

Thanks in advance, John

© Stack Overflow or respective owner

Related posts about wcf

Related posts about interfaces