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

  • Home
  • SEARCH
  • 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 161071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:08:51+00:00 2026-05-11T11:08:51+00:00

I have an asynchronous operation that for various reasons needs to be triggered using

  • 0

I have an asynchronous operation that for various reasons needs to be triggered using an HTTP call to an ASP.NET web page. When my page is requested, it should start this operation and immediately return an acknowledgment to the client.

This method is also exposed via a WCF web service, and it works perfectly.

On my first attempt, an exception was thrown, telling me:

Asynchronous operations are not allowed in this context. Page starting an asynchronous operation has to have the Async attribute set to true and an asynchronous operation can only be started on a page prior to PreRenderComplete event.

So of course I added the Async='true' parameter to the @Page directive. Now, I’m not getting an error, but the page is blocking until the Asynchronous operation completes.

How do I get a true fire-and-forget page working?

Edit: Some code for more info. It’s a bit more complicated than this, but I’ve tried to get the general idea in there.

public partial class SendMessagePage : System.Web.UI.Page {     protected void Page_Load(object sender, EventArgs e)     {         string message = Request.QueryString['Message'];         string clientId = Request.QueryString['ClientId'];          AsyncMessageSender sender = new AsyncMessageSender(clientId, message);         sender.Start();          Response.Write('Success');     } } 

The AsyncMessageSender class:

public class AsyncMessageSender {     private BackgroundWorker backgroundWorker;     private string client;     private string msg;      public AsyncMessageSender(string clientId, string message)     {         this.client = clientId;         this.msg = message;          // setup background thread to listen         backgroundThread = new BackgroundWorker();         backgroundThread.WorkerSupportsCancellation = true;         backgroundThread.DoWork += new DoWorkEventHandler(backgroundThread_DoWork);     }      public void Start()     {         backgroundThread.RunWorkerAsync();     }      ...     // after that it's pretty predictable } 
  • 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. 2026-05-11T11:08:52+00:00Added an answer on May 11, 2026 at 11:08 am

    If you don’t care about returning anything to the user, you can just fire up either a separate thread, or for a quick and dirty approach, use a delegate and invoke it asynchrnously. If you don’t care about notifying the user when the async task finishes, you can ignore the callback. Try putting a breakpoint at the end of the SomeVeryLongAction() method, and you’ll see that it finishes running after the page has already been served up:

    private delegate void DoStuff(); //delegate for the action  protected void Page_Load(object sender, EventArgs e) {  }  protected void Button1_Click(object sender, EventArgs e) {     //create the delegate     DoStuff myAction = new DoStuff(SomeVeryLongAction);      //invoke it asynchrnously, control passes to next statement     myAction.BeginInvoke(null, null);     Button1.Text = DateTime.Now.ToString(); }   private void SomeVeryLongAction() {     for (int i = 0; i < 100; i++)     {         //simulation of some VERY long job         System.Threading.Thread.Sleep(100);     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 69k
  • Answers 69k
  • 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
  • added an answer You can do zMzv or zMzO. zM closes all folds… May 11, 2026 at 12:26 pm
  • added an answer I got it, I must include my helpers manually, like:… May 11, 2026 at 12:26 pm
  • added an answer I believe you have two related issues here. The reason… May 11, 2026 at 12:26 pm

Related Questions

I have a question on the best way of exposing an asynchronous remote interface.
I have an absolutely positioned div containing several children, one of which is a
I have an array in Perl: my @my_array = (one,two,three,two,three); How do I remove
I'm re-designing an app I inherited that sends digital photos from a laptop to
Are there any sorts of useful idioms I can make use of when writing
I am implementing an asynchronous command pattern for the client class in a client/server

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.