The delegate explanation of the cache's add

Source: Internet
Author: User

Body

Think about it or write it, although the knowledge content is lower ....

Get the data into the cache, and add the result of their own with add is always reported parameter error, I wipe, I still feel is entrusted to the problem.

Call. Invoke ("Key", O, cacheitemremovedreason.removed);

System.Web.Caching.CacheItemRemovedCallback call = new System.Web.Caching.CacheItemRemovedCallback (Callback);

HTTPRUNTIME.CACHE.ADD ("I", o,null,datetime.now,20000, System.web.caching.cacheitempriority.default,call);

The problem arose, looking at the commission for a long while, still did not understand. In the final analysis of the delegation is not enough to understand, and finally looked at the use of the delegate, found that their usage is not a problem. Finally, you have to check the usage of Add.

HTTPRUNTIME.CACHE.ADD ("Key", O, NULL, DateTime.Now.AddSeconds (), TimeSpan.Zero, Cacheitempriority.high, call);

callback function no problem, just the time stamp problem, people are timespan type, I directly understand to write a number is OK. So this parameter is changed and there is no problem.

The point is actually to say is the meaning of the delegate, what is the delegate, define a delegate in fact, define a function variable, it can be easier to understand, when we put this delegate specific point to a specific method, in fact, is for the variable assignment process. If the delegate is not a parameter, then it can be called directly with just one curly brace. If it is a parameter, then it is OK to pass the variable name directly over it, as in the example above. I do not know whether to say that it is clear .... Welcome to the Great God of all directions

The delegate explanation of the cache's add

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.