473,503 Members | 1,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get the real method name of a Delegate


Hey all,

I pass my methods to be called into my function by Delegate.

Once inside my function which invokes them I'd like to get the orignal
name of the delegate if possible. I just want the name for reporting
purposes so I know which Delegate is being used for that particular
call.

Thanks in advance,

-Ralph

Jun 15 '07 #1
3 6001

"Deckarep" <de******@gmail.comwrote in message
news:11**********************@q19g2000prn.googlegr oups.com...
>
Hey all,

I pass my methods to be called into my function by Delegate.

Once inside my function which invokes them I'd like to get the orignal
name of the delegate if possible. I just want the name for reporting
purposes so I know which Delegate is being used for that particular
call.
It's all inside the Method property of every delegate. For a multicast
delegate, break it apart first using GetInvocationList.
>
Thanks in advance,

-Ralph
Jun 15 '07 #2
Deckarep <de******@gmail.comwrote:
I pass my methods to be called into my function by Delegate.

Once inside my function which invokes them I'd like to get the orignal
name of the delegate if possible. I just want the name for reporting
purposes so I know which Delegate is being used for that particular
call.
Yes - use Delegate.GetInvocationList. Note that a single delegate
instance can contain many actions due to them being combined together.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jun 15 '07 #3
On Jun 15, 2:07 pm, Jon Skeet [C# MVP] <s...@pobox.comwrote:
Deckarep <decka...@gmail.comwrote:
I pass my methods to be called into my function by Delegate.
Once inside my function which invokes them I'd like to get the orignal
name of the delegate if possible. I just want the name for reporting
purposes so I know which Delegate is being used for that particular
call.

Yes - use Delegate.GetInvocationList. Note that a single delegate
instance can contain many actions due to them being combined together.

--
Jon Skeet - <s...@pobox.com>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Thanks guys, that worked....wasn't sure where to look and this time
around Google was not my friend...bad Google.

Jun 15 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2631
by: Jim Witt | last post by:
Ref: Win2000, .NET 1.1 I want to place series of buttons on a form, my own button class. Would like to create descriptor array to describe buttons - each needs: text, x and y position, and...
3
3926
by: Clinton Pierce | last post by:
I can create a delegate like this, and everything works fine: class Foo { private delegate void NextPanel(); private NextPanel myself; // And later in a method private void EffStart() {
1
2365
by: Pieter Breed | last post by:
Hi All, I am trying to use the attribute/reflection system to as much potential as I can think of, but I've run into a snag. I would appreciate it if someone would point me in the right...
1
3716
by: Ajay Pal Singh | last post by:
Hi, I am making an windows service similar to windows task schedular. The service would invoke the methods of some assemblies at some predefined schedules. (windows service read the...
18
4705
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
7
3774
by: Bill Woodruff | last post by:
I've found it's no problem to insert instances of named delegates as values into a generic dictionary of the form : private Dictionary<KeyType, DelegatemyDictionary = new Dictionary<KeyType,...
3
1766
by: William Stacey [C# MVP] | last post by:
It would be handy to be able to ref "this" from inside an AM such as: (string s) { Console.Writeline(s); DoSomething(this); } So treating am like a method of a class (which it is)....
6
39423
by: Dom | last post by:
I'm teaching myself about delegates and the Invoke method, and I have a few newbie questions for the gurus out there: Here are some CSharp statements: 1. public delegate void MyDelegate (int k,...
3
1869
by: Robert Howells | last post by:
Is there any such thing as an "anonymous delegate"? I understand what an anonymous method is, but I'm unclear of the concept of anonymous delegate (if it is even a valid term to be using). Is an...
0
7198
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7072
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7271
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7319
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6979
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4998
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.