473,568 Members | 2,986 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 6018

"Deckarep" <de******@gmail .comwrote in message
news:11******** **************@ q19g2000prn.goo glegroups.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 GetInvocationLi st.
>
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.GetInv ocationList. Note that a single delegate
instance can contain many actions due to them being combined together.

--
Jon Skeet - <sk***@pobox.co m>
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.com wrote:
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.GetInv ocationList. 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
2637
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 method invoked when button clicked. I've been able to create descriptor with 'text, x, y' just fine (no brainer). However, I designate button click...
3
3929
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
2370
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 direction. First my question: How am I supposed to make instances of delegates when I have the method (that I want to make the delegate of) retrieved...
1
3728
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 method/assembly and schedule info from app.config file) I am using reflection to dynamically load the assemblies and then want to call a method of that assembly...
18
4721
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 class where only the "searched" property has a value. I expected to get the index into the arraylist where I could then get the entire class...
7
3783
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, Delegate); using the standard .Add method of the Dictionary, passing in the name of the delegate instance for the value. private void...
3
1767
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). Currently we have no context to know so you have to pass that as state which seems kinda
6
39427
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, string s) 2. MyDelegate MyDelegateVar = MyMethod 3. MyForm.Invoke (MyDelegateVar) Some questions:
3
1872
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 "anoymous delegate" simply an anonymous method used in conjunction with a delegate declaration? Thanks!
0
7605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2105
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.