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 7127859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:04:38+00:00 2026-05-28T11:04:38+00:00

I have a normal method public List<string> FindNearByCity(string targetCity) { // … some implementation

  • 0

I have a normal method

public List<string> FindNearByCity(string targetCity)
{
// ... some implementation
}

I want to add async support for this method, so i wrote this:

public IAsyncResult BeginFindNearByCity(string targetCity, AsyncCallback callback, object obj)
{
    Func<string, List<string>> method = FindNearByCity;
    return method.BeginInvoke(targetCity, callback, obj);
}

public List<string> EndFindNearByCity(IAsyncResult  result)
{
    Func<string, List<string>> method = FindNearByCity;
    return method.EndInvoke(result);
}

The BeginFindNearByCity works fine, however when it comes to EndFindNearByCity, exception will throw when it hit EndInvoke.

I look into the auto gen Async web service method, seems i need to implement something call “ChannelBase”

can anyone point me to something that more simple like tutorial or sample that i can have a look at?

Thanks

  • 1 1 Answer
  • 0 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-28T11:04:39+00:00Added an answer on May 28, 2026 at 11:04 am

    The delegate you are creating in your EndXXX method is a separate instance to the delegate you create in your BeginXXX method, therefore it has no knowledge of the IAsyncResult which you are passing to its EndInvoke() method.

    You have to use the same delegate in the EndXXX method as the BeginXXX method, e.g.

    public class Foo
    {
        private readonly Func<string, List<string>> method;
    
        public Foo()
        {
            this.method = this.FindNearByCity;
        }
    
        public IAsyncResult BeginFindNearByCity(string targetCity, AsyncCallback callback, object obj)
        {
            return this.method.BeginInvoke(targetCity, callback, obj);
        }
    
        public List<string> EndFindNearByCity(IAsyncResult  result)
        {
            return this.method.EndInvoke(result);
        }
    
        public List<string> FindNearByCity(string targetCity)
        {
            // ... some implementation
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a normal asp.net page containing some code that I want to measure
Say I have a method: public void SomeMethod(String p1, String p2, int p3) {
I have a plain normal class, e.g.: public class ObjectA { public string val
Is it normal to modify setter arguments? Let's imagine that we have setString method.
Normal overriding would work this way: class Fruit { public: string color(); }; string
public void wahey(List<Object> list) {} wahey(new LinkedList<Number>()); The call to the method will not
I have created a custom HandlerInterceptorAdapter to override the postHandle method: public class AcmeInterceptor
I have a pieces of code: The method is as follows: public IEnumerable<c> Test(){
I have this class public class Overloaded { public void ComplexOverloadResolution(params string[] something) {
I have the following helper method that returns the value from a field. public

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.