Share via


IMetaDataEmit::DefineEvent Method

Creates a definition for an event with the specified metadata signature, and gets a token to that event definition.

HRESULT DefineEvent ( 
    [in]  mdTypeDef    td, 
    [in]  LPCWSTR      szEvent, 
    [in]  DWORD        dwEventFlags, 
    [in]  mdToken      tkEventType, 
    [in]  mdMethodDef  mdAddOn, 
    [in]  mdMethodDef  mdRemoveOn, 
    [in]  mdMethodDef  mdFire, 
    [in]  mdMethodDef  rmdOtherMethods[], 
    [out] mdEvent      *pmdEvent 
);

Parameters

  • td
    [in] The token for the target class or interface. This is either a mdTypeDef or mdTypeDefNil token.

  • szEvent
    [in] The name of the event.

  • dwEventFlags
    [in] Event flags.

  • tkEventType
    [in] The token for the event class. This is a mdTypeDef, a mdTypeRef, or a mdTokenNil token.

  • mdAddOn
    [in] The method used to subscribe to the event, or null.

  • mdRemoveOn
    [in] The method used to unsubscribe to the event, or null.

  • mdFire
    [in] The method used (by a derived class) to raise the event.

  • rmdOtherMethods[]
    [in] An array of tokens for other methods associated with the event. The array is terminated with a mdMethodDefNil token.

  • pmdEvent
    [out] The metadata token assigned to the event.

Requirements

Platforms: See .NET Framework System Requirements.

Header: Cor.h

Library: Used as a resource in MSCorEE.dll

.NET Framework Versions: 4, 3.5 SP1, 3.5, 3.0 SP1, 3.0, 2.0 SP1, 2.0, 1.1, 1.0

See Also

Reference

IMetaDataEmit Interface

IMetaDataEmit2 Interface