Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 747685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:14:02+00:00 2026-05-14T14:14:02+00:00

I am trying to figure out if it is possible to implement a .NET

  • 0

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

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:14:02+00:00Added an answer on May 14, 2026 at 2:14 pm

    Apparently I misunderstood the original question, which was about how to use the asynchronous methods on a client proxy.

    The answer is that you don’t return from an asynchronous method call. It wouldn’t be asynchronous if you could. If you are trying to encapsulate an asynchronous method on a WCF client, then you should encapsulate a callback instead of a return value:

    public interface IDataService
    {
        void SendDataRequest(Action<IDataServiceResponse> callback);
    }
    
    public class DataService
    {
        public void SendDataRequest(Action<IDataServiceResponse> callback)
        {
            InitializeDataServiceParameters();
            _client.BeginQueryJobs(_parameters, DataServiceQueryCallBack, callback);
        }
    
        private void DataServiceQueryCallBack(IAsyncResult result)
        {
            var response = _client.EndQueryJobs(ar);
            // Convert the actual WCF response into your custom interface
            var dataServiceResponse = TranslateResponse(response);
            Action<IDataServiceResponse> callback = 
                (Action<IDataServiceResponse>)result.AsyncState;
            if (callback != null)
                callback(dataServiceResponse);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm completely new to Actionscript and I'm trying to figure out if it's possible
I'm trying to figure out how to implement a function in a tree node
I'm trying to figure out if it would be possible to stick to the
I learned something new while trying to figure out why my readwrite property declared
Trying to figure out an equation to get the current group a page would
In trying to figure out this problem (which is still unsolved and I still
I'm trying to figure out how big a certain database would be (it hasn't
I'm basically trying to figure out the simplest way to perform your basic insert
I'm trying to figure out why the control does not honor ZIndex. Example 1
I've been trying to figure out a regex to allow me to search for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.