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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:42:01+00:00 2026-05-26T17:42:01+00:00

Me and my co-worker have been discussing async procedures. Example: ws.GetAllEventsAsync(123, 123); ws.GetAllEventsCompleted +=

  • 0

Me and my co-worker have been discussing async procedures.

Example:

ws.GetAllEventsAsync("123", "123");
ws.GetAllEventsCompleted += new awc5ws.events.GetAllEventsCompletedEventHandler(ws_GetAllEventsCompleted);

ws in this case is a web service (asmx).

Now, is it possible that the first line of code, executes and finishes before the compiler reaches the 2nd line, thus the callback function is not executed.

So in this case, would it make more sense to attach the event handler callback before actually executing the Web Method? Like so:

ws.GetAllEventsCompleted += new awc5ws.events.GetAllEventsCompletedEventHandler(ws_GetAllEventsCompleted);
ws.GetAllEventsAsync("123", "123");

I don’t know if I’m making much sense here, but I hope you can understand my point. I would appreciate if you could go into detail rather than a yes or no answer.

Thanks in advance

  • 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-26T17:42:02+00:00Added an answer on May 26, 2026 at 5:42 pm

    Yes and yes 🙂

    Your first example is a race condition. If you run it, it might work, or it might not. That’s actually worse than not working at all.

    Sometimes, the call to ws.GetAllEventsAsync may even execute synchronously, in which case the bug is evident. When it executes asynchronously, it may still complete before your main thread attaches the event handler and you will miss the event.

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

Sidebar

Related Questions

I have been working on implementing a (1) server, (n) worker role servers setup
I have been working on a project where I have a Worker class that
I have been reading up on HTML 5 worker threads but all the samples
I have been trying to follow this example (download the source code from a
Hi I'm very new to sql but have been passed a job in which
I have been discussing with a fellow developer about product deployment of a webbased
I'm new to concurrent programing and have been working on code which has a
Another co-worker and I have been heavily modifying the PHP Zookeeper extension but the
I have a working WCF service and worker role that I have been debugging
I'm new to multi-threading and I have been doing a Proof-of-Concept, I've also 'discovered'

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.