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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:09:48+00:00 2026-05-13T01:09:48+00:00

1) I heard that when we won’t call EndInvoke() it may lead to memory

  • 0

1) I heard that when we won’t call EndInvoke() it may lead to memory leak? can you demonstrate it how could this lead to memory leak?

2) When i suppose to call EndInvoke() shall i use the code like following ?

namespace BlockMechanism
{
    public delegate int MyDelegate(List<int> someInts);
    class MainClass
    {
        static void Main()
        {
           List<int> someInts = new List<int> { 1, 2, 3, 4, 5, 6, 7 };
           MyDelegate test = FinalResult;
           IAsyncResult res=test.BeginInvoke(someInts, null, test);
           Console.WriteLine(test.EndInvoke(res));
           Console.ReadKey(true);
        }

        public static int FinalResult(List<int> Mylist)
        {
            return Mylist.Sum();
        }

    }
}
  • 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-13T01:09:49+00:00Added an answer on May 13, 2026 at 1:09 am

    While your example is correct there is no benefit from using a different thread because you call EndInvoke on the main thread which will block until the operation completes and it cannot do other work. It would have been equivalent if you called Invoke on the delegate or directly the FinalResult method itself. Usually EndInvoke is called in the callback provided by the BeginInvoke method:

    class Program
    {
        public delegate int MyDelegate(List<int> someInts);
        class MainClass
        {
            static void Main()
            {
                List<int> someInts = new List<int> { 1, 2, 3, 4, 5, 6, 7 };
                MyDelegate test = FinalResult;
                test.BeginInvoke(someInts, ar => 
                {
                    MyDelegate del = (MyDelegate)ar.AsyncState;
                    Console.WriteLine(del.EndInvoke(ar));
                }, test);
                Console.ReadKey(true);
            }
    
            public static int FinalResult(List<int> Mylist)
            {
                return Mylist.Sum();
            }
        }
    }
    

    As far as the memory leak is concerned you may take a look at this thread.

    P.S: Instance members of the List<T> class are not thread safe so you should be careful when you access them from multiple threads.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 263k
  • Answers 263k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Markus wrote : "if another control is dragged to my… May 13, 2026 at 12:00 pm
  • Editorial Team
    Editorial Team added an answer What do you need most: The ability to make sure… May 13, 2026 at 12:00 pm
  • Editorial Team
    Editorial Team added an answer The only (standard) way is to look in the HTTP… May 13, 2026 at 12:00 pm

Related Questions

1) I heard that when we won't call EndInvoke() it may lead to memory
We have started building an asp.net mvc application. Application will consist with one main
We have an external .js file that we want to include in a number
I'm a student of webdevelopment and I've got a question about the business (after
When I first heard about StackOverflow, and heard that it was being built in

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.