Delegate that gets called when an event-out slot sends an event.
Namespace: Vrml.EAI.Event
Assembly: VrmlEAI.NET
Collapse/Expand Syntax
C#
public delegate void VrmlEventDelegate (
        VrmlEvent evt
) 
Parameters
evt
A VrmlEvent object that contains information about the event.
Collapse/Expand Remarks

This delegate defines the signature of a method that gets called when an event-out slot sends an event. Write a method that has the same signature, add it to the EventOut object by calling its AddVrmlEventDelegate method, and that method will be called when the slot fires an event. The VrmlEvent object you'll receive as a parameter of the method contains more information about the specific event. When you're no longer interested in receiving events, remove the delegate from the EventOut object by calling its RemoveVrmlEventDelegate method.

Warning: Something really important that you have to keep in mind about vrml event delegates is that they get called by a special thread created inside the EAI implementation, not by the main thread of your application. For this reason, you have to synchronize access to variables and calls to other methods, i.e. you have to make your code thread-safe. For more information about thread-safety, read a good book about thread programming in C#. The EAI interface itself is thread-safe, therefore you do not have to care about thread synchronization when calling EAI methods. Also keep in mind that your code inside the delegate should not block - as long as the thread is inside your delegate, no other delegate gets called. For performance reasons, do not try to do long-winded operations in your delegate, instead return as soon as possible. If you need to perform lengthy operations, create a new thread to do them.

Collapse/Expand Example
The following example shows the skeleton of a VRML event delegate, and it demonstrates how to add the delegate to an EventOut object, and how to remove the delegate when you're finished:
C#
public class MyClass
{
    private static Vrml.EAI.Field.EventOutSFColor diffuseColor_changed;
            
    private static void OnVrmlEvent(Vrml.EAI.Event.VrmlEvent evt)
    {
        Vrml.EAI.Field.BaseField field = evt.Source;
        double time = evt.Time;
        object data = evt.Data;
        if (field == diffuseColor_changed)
        {
            // diffuseColor_changed event-out slot fired an event
            ...
        }
        ...
    }
            
    public static void Main(string[] args)
    {
        ...
        diffuseColor_changed = ...;
        diffuseColor_changed.AddVrmlEventDelegate(OnVrmlEvent);
        ...
        diffuseColor_changed.RemoveVrmlEventDelegate(OnVrmlEvent);
        ...
    }
}