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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:47:02+00:00 2026-06-14T07:47:02+00:00

Can I be sure that .Method.MethodHandle.GetFunctionPointer() is unique for each anonymous function? Want to

  • 0

Can I be sure that .Method.MethodHandle.GetFunctionPointer() is unique for each anonymous function?
Want to do

public static T Get<T>(Func<T> getDataCallback) where T : class
{
    string cacheID = getDataCallback.Method.MethodHandle.GetFunctionPointer().ToString();
    var data = HttpRuntime.Cache.Get(cacheID) as T;
    if (data == null)
    {
        data = getDataCallback();
        HttpContext.Current.Cache.Insert(cacheID, data);
    }
    return data;
}
  • 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-06-14T07:47:04+00:00Added an answer on June 14, 2026 at 7:47 am

    I think you mean anonymous delegates. Different delegates have different d.Method.MethodHandle.GetFunctonPointer() results, but first we need to define “different delegates”. If two delegates refers to the same method, they are considered the same, like:

    Action a = new Action(MyMethod);
    Action b = new Action(MyMethod);   
    //a == b, that is, Delegate.Equals(a,b) is true
    

    Anonymous delegates are always different, even they look the same:

    Action a = delegate { MyMethod(); }; 
    Action b = delegate { MyMethod(); };
    

    So the answer to your first question is YES, but your cache possibly won’t work as expected! If your application pool is recycled, the FunctionPointer value will change even your getDataCallback delegate remains the same. Be aware of this.

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

Sidebar

Related Questions

If i use ConcurentDictionary dic in multithread accessed method can i be sure that
I have an extension method with the following signature: public static Expression<Func<T, bool>> And<T>(this
I'm currently looking into the RegisterClientScriptInclude method so I can be sure that I
How can i make sure that several divs are slided up? Right now I
My question is simple: WHEN (on what event?) can I be sure that a
How can use regex to make sure that is only a single slash end
I'm not even sure that Postgres' HStore data type can contain nested hashes, and
I would like to make sure that an applescript can be converted to bash.
I'm not sure that title conveys my meaning, please change it if you can
I need to validate a user's screen name to make sure that it can

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.