This article is a mirror article of machine translation, please click here to jump to the original article.

View: 64806|Reply: 2

[Source] .net/c# event for details

[Copy link]
Posted on 5/29/2018 1:18:13 PM | | | |
Definition of events in C#:

A class or object can notify other classes or objects of what has happened through events. The class that sends (or causes) the event is called the "issuer" and the class that receives (or processes) the event is called the "subscriber".

Events have the following characteristics:

  • The publisher determines when to raise the event, and the subscriber determines what action to perform in response to the event.
  • An event can have multiple subscribers. A subscriber can handle multiple events from multiple issuers.
  • Events without subscribers are never called.
  • Events are often used to inform users of actions, such as button clicks or menu selection actions in graphical user interfaces.
  • If an event has multiple subscribers, multiple event handlers are called simultaneously when the event is raised. To call events asynchronously, see Calling Synchronization Methods Using Asynchronous.
  • Event synchronization threads can be leveraged.

The event keyword is used to declare events in the publisher class.

ms link:The hyperlink login is visible.





There is actually no difference between event writing method A and writing method B!

You can refer to:The hyperlink login is visible.

EventHandler<T>Represents a method that accepts two parameters (object sender, TEventArgs e) and returns a void type. where TEventArgs must be a type derived from the EventArgs class. The latter parameter is used to store the parameters required for the event.

EventArgsis the base class of a class that contains event data, which does not contain event data, and is used by events that do not pass state information to the event handler when the event is raised. If the event handler needs state information, the application must derive a class from this class to hold the data.

Volatile.Read  .NET 4.0 is not supported


//
        Summary:
        Object references read from the specified field. When it is needed on the system, a memory barrier will be inserted to prevent the processor from reordering memory operations, as shown below: If this method appears in the code after performing a read/write, the processor cannot move it before this method.
        //
        Parameters:
        //   location:
        fields to read.
        //
        Type parameters:
        //   T:
        The type of field to be read. This must be the reference type, not the value type.
        //
        Return results:
        Read to the reference T. This reference is written by any processor in the computer, regardless of the number of processors or the state of the processor cache.
        [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]
        [SecuritySafeCritical]
        [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
        public static T Read<T>(ref T location) where T : class;






Previous:The QQ version of Android mobile phones has scolded "easter eggs"
Next:c# to read the file encapsulation of OpenFileDialog
 Landlord| Posted on 3/22/2020 5:11:32 PM |
.NET 4.0 Writing Method
Define event parameters


Define the event



Trigger events



 Landlord| Posted on 3/17/2021 11:21:40 AM |
ASP.NET Core uses the MediatR intermediary model
https://www.itsvse.com/thread-9272-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com