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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:19:35+00:00 2026-05-19T01:19:35+00:00

I’m working on a C# application in which I set up a few asynchronous

  • 0

I’m working on a C# application in which I set up a few asynchronous function calls using delegates. These calls will be subject to multiple-invocations, so I have to use the overload of the delegate’s BeginInvoke method which takes a userState argument; e.g.:

callerDelegate.BeginInvoke([fn_args...], callback, userState)

On the Event-based Asynchronous Pattern Overview page on MSDN, it says about userState:

There are potentially two overloads
for the asynchronous operations:
single-invocation and
multiple-invocation. You can
distinguish these two forms by their
method signatures: the
multiple-invocation form has an extra
parameter called userState. This form
makes it possible for your code to
call Method1Async(string param, object
userState) multiple times without
waiting for any pending asynchronous
operations to finish. If, on the other
hand, you try to call
Method1Async(string param) before a
previous invocation has completed, the
method raises an
InvalidOperationException.

The userState parameter for the
multiple-invocation overloads allows
you to distinguish among asynchronous
operations. You provide a unique value
(for example, a GUID or hash code) for
each call to Method1Async(string
param, object userState), and when
each operation is completed, your
event handler can determine which
instance of the operation raised the
completion event.

My question is: does the userState have to be unique? The wording can be construed to make it merely a recommendation, or just pertinent to their example. I do need to pass state to the callback, I just don’t need it to be unique. (My application does not need to keep track of each individual instance of the call.) So, is uniqueness a requirement? (Perhaps the asynchronous framework of .NET needs it?)

Also, the quoted page is for event-based asynchronous operations; does this apply to my case (asynchronous calls using delegates) as well?

I’ve searched google and SO for a couple of days and have yet to find an 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-19T01:19:36+00:00Added an answer on May 19, 2026 at 1:19 am

    It does not apply to your case. Begin/End are the IAsyncResult asynchronous pattern, not the Event-based Asynchronous Pattern (EAP).

    It affects EAP because usually the implementation uses AsyncOperationManager.CreateOperation, which requires a unique user state. Even in this case, it’s (usually) valid for end-user code to pass a null user state; the EAP component would replace that with a new object when it calls CreateOperation.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm making a simple page using Google Maps API 3. My first. One marker
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I want use html5's new tag to play a wav file (currently only supported
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.