fourteen.8.dos Occupation-for example situations
From inside the program text message of one’s category or struct that features this new statement from a meeting, certain occurrences can be utilized for example industries. Instance an event can be utilized in any context that enables an industry. Industry include an excellent subcontract (§19), which refers to the directory of experience handlers which were put in the big event. If zero enjoy handlers were extra, industry include null .
Mouse click can be used once the an industry in Button category. Because analogy shows, industry are checked, altered, and used in outsource invocation words. The OnClick strategy in the Option group “raises” the newest Simply click feel. The thought of elevating an event is precisely equal to invoking the fresh subcontract portrayed from the enjoy-thus, there aren’t any special language constructs having elevating situations. Note that the brand new outsource invocation is actually preceded by the a check that assurances the brand new subcontract is non-null and this the new check is established toward a community copy to ensure thread cover.
Outside of the declaration of Key classification, the fresh Simply click user are only able to be used on leftover-give region of the += and you can –= providers, like in
When putting together an industry-including skills, the fresh compiler instantly brings shop to hold new delegate, and helps to create accessors to the knowledge one put or treat feel handlers into the delegate industry. The new inclusion and you may elimination functions is actually thread safe, and might (but are not required so you can) be achieved if you find yourself holding the new lock (§9.cuatro.cuatro.19) regarding that has object to possess an incident enjoy, and/or form of object (§11.7.fifteen.7) to own a static enjoy.
Within the category X , references so you’re able to Ev towards leftover-hands side of the += and you will –= operators result in the incorporate and remove accessors as invoked. All other recommendations in order to Ev is actually accumulated so you can resource the invisible industry __Ev instead (§11.eight.6). The name ” __Ev ” is arbitrary; brand new hidden community might have any title if any label at most of the. stop mention
fourteen.8.step 3 Experiences accessors
Note: Enjoy declarations typically leave out skills_accessor_ple, they are provided in case your shop cost of one to community for each enjoy is not appropriate. In such instances, a category may include skills_accessor_declarations and use a personal process getting storing the list of knowledge handlers. end notice
The fresh datingranking.net/pl/mate1-recenzja accessor declarations include an incorporate_accessor_report and a remove_accessor_declaration. For every accessor report contains the new token incorporate otherwise clean out adopted by a great block. The latest take off with the a contain_accessor_declaration determine the new comments to perform whenever a meeting handler try additional, additionally the stop regarding the a strip_accessor_report specifies the fresh statements to do when a meeting handler was removed.
Each incorporate_accessor_declaration and take away_accessor_declaration corresponds to a method with just one well worth factor from case type of, and a gap come back style of. New implicit parameter out-of an event accessor is known as worth . Whenever an event is utilized from inside the a meeting project, the proper knowledge accessor is utilized. Particularly, if your assignment agent are += then your include accessor is employed, if in case brand new task user was –= then your eliminate accessor is utilized. In any event, best-give operand of your own task agent can be used while the conflict toward feel accessor. This new block from an use_accessor_report or a remove_accessor_statement shall adhere to the rules to have void actions described inside §14.6.9. Specifically, get back statements such a good cut off are not permitted to establish a term.
Since a conference accessor implicitly has a factor called worthy of , it’s an amass-date mistake to own a region changeable or constant e.
the Handle classification implements an inside shops device to have events. The fresh new AddEventHandler method lovers a great subcontract really worth with a button, the new GetEventHandler strategy yields the fresh outsource currently associated with the a button, together with RemoveEventHandler method takes away good delegate since a conference handler with the specified feel. Allegedly, the underlying shop device is designed in a fashion that there’s absolutely no prices getting accompanying an effective null outsource value which have a key, which means that unhandled occurrences consume no storage. avoid analogy