Delegate that gets called when the status of a browser changes.
Namespace: Vrml.EAI.Event
Assembly: VrmlEAI.NET
Collapse/Expand Syntax
C#
public delegate void BrowserDelegate (
        BrowserEvent evt
) 
Parameters
evt
A BrowserEvent object that contains information about the event.
Collapse/Expand Remarks

This delegate defines the signature of a method that receives information about X3D browser status changes. Write a method that has the same signature, add it to the Browser object by calling its AddBrowserDelegate method, and that method will be called when the status changes. The BrowserEvent 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 status change information, remove the delegate from the Browser object by calling its RemoveBrowserDelegate method.

Warning: Something really important that you have to keep in mind about browser 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 browser delegate, and it demonstrates how to add the delegate to the Browser object, and how to remove the delegate when you're finished:
C#
public class MyClass
{
    private static void OnBrowserEvent(Vrml.EAI.Event.BrowserEvent evt)
    {
        // Get the Browser object whose status changed
        Vrml.EAI.Browser browser = evt.Source;
        switch (evt.ID)
        {
        case Vrml.EAI.Event.BrowserEvent.INITIALIZED:
            // The browser finished to load a new scene
            ...
            break;
        case Vrml.EAI.Event.BrowserEvent.SHUTDOWN:
            // The browser is about to unload a scene
            ...
            break;
        case Vrml.EAI.Event.BrowserEvent.URL_ERROR:
            // Download from an URL failed
            ...
            break;
        case Vrml.EAI.Event.BrowserEvent.CONNECTION_ERROR:
            // An error occurred in the communication with the browser
            ...
            break;
        }
    }
            
    public static void Main(string[] args)
    {
        ...
        Vrml.EAI.Browser browser = ...;
        browser.AddBrowserDelegate(OnBrowserEvent);
        ...
        browser.RemoveBrowserDelegate(OnBrowserEvent);
        ...
    }
}