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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:18:47+00:00 2026-06-08T00:18:47+00:00

Replacing Threads (not ThreadPool Thread) with Asynchronous Delegates (Callbacks). My Scenario: Spawn a Thread/del.beginInvoke()

  • 0

Replacing Threads (not ThreadPool Thread) with Asynchronous Delegates (Callbacks).

My Scenario: Spawn a Thread/del.beginInvoke() per Client.

According to me,

Reasons

  1. need for Notification via Callback / Call delegate again in Callback
  2. Avoid Thread Overhead, (delegates use Threadpool thread)
  3. Passing Arguments (Avoid Casting to object) and need return value from the method.

Correct me if above reasons are wrong.

  1. Is any other Reasons?
  2. What scenario i exactly need to do some stuff with Asynchronous Delegates that
    threads can’t?
    3.Performance ?

Example

    public delegate void SendCallbackType();

    SendCallbackType senderdel= new SendCallbackType(SendData);

    public void StartSend() // This method Could be Called more than 700 times (Thread per Client)
    {
        senderdel.BeginInvoke(SendCallback,null);
                   // (or)
        Thread t = new Thread(new ThreadStart(ThreadSend));
        t.IsBackground = true;
        t.Start();
    }

  //Async Delegate
    void SendData()
    {
         string data = QueData.DeQueue();
         RaiseOnData(data); // Raise to event.
    }
    void SendCallback(IAsyncResult ar)
    {
        senderdel.BeginInvoke(SendCallback, null);
    }

 //Thread
  void ThreadSend()
  {
      while (true)
      {
         string data = QueData.DeQueue();
         RaiseOnData(data); // Raise to event.
      }
   }

From the above which option would be the best. Performance ?

  • 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-06-08T00:18:49+00:00Added an answer on June 8, 2026 at 12:18 am

    Your reasoning is correct. Async delegates use threads from the thread pool so they should be faster compared to manual thread creation. Be careful though with this in ASP.NET applications. Because you will be eating up worker threads that are normally used by ASP.NET to service requests and your application might very quickly run out of servicing capabilities.

    Async delegates are fine for CPU intensive tasks. For I/O intensive tasks (such as reading streams, database calls and web service calls) you should use the BeginXXX, EndXXX methods offered directly by the corresponding classes (Stream, SqlConnection, WebClient, …). This way you are not using any threads at all during the lengthy I/O operation. You are using I/O Completion Ports which is the best thing in terms of I/O bound tasks. It will be orders of magnitude more performant and resource cheap than any threads and pools of threads.

    So to summarize:

    • For I/O intensive tasks use I/O Completion Ports. If the I/O intensive task is wrapped inside a poorly written library that doesn’t offer this possibility use the TPL that was introduced in .NET 4.0.
    • For CPU intensive tasks use the TPL that was introduced in .NET 4.0.

    And if you don’t have .NET 4.0 use thread pool unless you are writing an ASP.NET application in which case you might resort to manual thread creation.

    In general it is good practice to start using TPL and orient your methods as tasks so that you are ready for .NET 4.5 which introduces the async/await keywords.

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

Sidebar

Related Questions

I get this error message: Exception in thread main java.lang.ArithmeticException: BigInteger not invertible. This
i discovered that a wxCriticalSection is not recursive ( does deadlock when a thread
I found only one thread relating to this but it did not answer the
I found threads where people had troubles with invalidate because they were not on
My scenario: I have a background thread that polls for changes and periodically updates
Replacing the Special Character using Perl while i am doing this . I got
While replacing a pattern in a string, I specifically need the integer/long value of
I'm replacing all the inline gist snippets w/ a div to load them in
I am replacing some deprecated Javadoc annotation in code I am unfamiliar with. Most
We're replacing a static web-site with a Django app. All the uri's will change.

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.