Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CodeDelegateInvokeExpression Class

Represents an expression that raises an event.

For a list of all members of this type, see CodeDelegateInvokeExpression Members.

System.Object
   System.CodeDom.CodeObject
      System.CodeDom.CodeExpression
         System.CodeDom.CodeDelegateInvokeExpression

[Visual Basic]
<Serializable>
<ClassInterface(ClassInterfaceType.AutoDispatch)>
<ComVisible(True)>
Public Class CodeDelegateInvokeExpression
   Inherits CodeExpression
[C#]
[Serializable]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ComVisible(true)]
public class CodeDelegateInvokeExpression : CodeExpression
[C++]
[Serializable]
[ClassInterface(ClassInterfaceType::AutoDispatch)]
[ComVisible(true)]
public __gc class CodeDelegateInvokeExpression : public
   CodeExpression
[JScript]
public
   Serializable
 ClassInterface(ClassInterfaceType.AutoDispatch)
 ComVisible(true)
class CodeDelegateInvokeExpression extends CodeExpression

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

CodeDelegateInvokeExpression can be used to represent code that invokes an event. Invoking an event invokes all delegates that are registered with the event using the specified parameters.

The TargetObject property specifies the event to invoke. The Parameters property specifies the parameters to pass to the delegates for the event.

Example

[Visual Basic, C#, C++] The following example demonstrates use of a CodeDelegateInvokeExpression to invoke an event named TestEvent.

[Visual Basic] 
' Invokes the delegates for an event named TestEvent, passing a local object reference and a new System.EventArgs.
Dim invoke1 As New CodeDelegateInvokeExpression( _
    New CodeEventReferenceExpression(New CodeThisReferenceExpression(), "TestEvent"), _
    New CodeExpression() {New CodeThisReferenceExpression(), New CodeObjectCreateExpression("System.EventArgs")})

' A Visual Basic code generator produces the following source code for the preceeding example code:

'   RaiseEvent TestEvent(Me, New System.EventArgs())            

[C#] 
// Invokes the delegates for an event named TestEvent, passing a local object reference and a new System.EventArgs.
CodeDelegateInvokeExpression invoke1 = new CodeDelegateInvokeExpression( new CodeEventReferenceExpression(new CodeThisReferenceExpression(), "TestEvent"), 
    new CodeExpression[] { new CodeThisReferenceExpression(), new CodeObjectCreateExpression("System.EventArgs") } );

// A C# code generator produces the following source code for the preceeding example code:

//    this.TestEvent(this, new System.EventArgs());

[C++] 
// Invokes the delegates for an event named TestEvent, passing a local object reference and a new System.EventArgs.

CodeExpression* temp1 [] = {new CodeThisReferenceExpression(), new CodeObjectCreateExpression(S"System.EventArgs",0)};

CodeDelegateInvokeExpression* invoke1 = new CodeDelegateInvokeExpression( new CodeEventReferenceExpression(new CodeThisReferenceExpression(), S"TestEvent"), 
    temp1 );

// A C# code generator produces the following source code for the preceeding example code:

//    this.TestEvent(this, new System.EventArgs());

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.CodeDom

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System (in System.dll)

See Also

CodeDelegateInvokeExpression Members | System.CodeDom Namespace | CodeExpression

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft