Silly delegate question

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

How many superdelegates does it take to screw in a lightbulb?

No... I was wondering if an instance of delegate stateful or can it be
reused?

For example you see a lot of (new AsyncCallback (method), param) it i/o
calls. If the delegate itself isn't carrying state, it seems like you could
have

static AsyncCallback myAsyncDelegate = new AsyncCallback (method);
....
AsyncOpofChoice.Beginxxx( myAsyncDelegate, param);

Thanks
Mark
 
Mark said:
How many superdelegates does it take to screw in a lightbulb?

No... I was wondering if an instance of delegate stateful or can it be
reused?

It can certainly be effectively stateful, in that the target of a
delegate may change as the result of calling the delegate. However, if
you would be using the same target and the same action, there is indeed
no reason to create another instance each time.
 
Thanks Jon and Peter for your replies!

Hi Mark,

I agree with Jon and Peter. But I couldn't understand your real question
exactly.

If you haven't got the answer you want to this question, could you please
explain more about the question?

I look forward to your reply!

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Linda (and Jon and Peter)...

Yes, this was very helpful - especially Peter's clarification that it's as
stateful as the method you make a delegate of and the interactions it has. I
was wondering if there was any state kept in the delegate object itself; I
figured there probably wasn't but just wanted to be sure.

Thank you all for your responses.

Mark
 
Back
Top