StreamLink.NET
IExceptionHandler Interface
StreamLink.NETCaplin.StreamLinkIExceptionHandler
Definition of the interface that receives exceptions generated by StreamLink.NET on non-user controlled threads.
Declaration Syntax
C#Visual BasicVisual C++
public interface IExceptionHandler
Public Interface IExceptionHandler
public interface class IExceptionHandler
Members
All MembersMethods



IconMemberDescription
HandleException(Exception)
Handles a StreamLink .NET exception.

Remarks

It is recommended that you implement the IExceptionHandler interface, so your application can handle exceptions generated by StreamLink. Such an exception indicates that the internal state of the StreamLink.NET library can no longer be relied upon as being correct.

Important

Your exception handler should shut the application down gracefully, since the only way to recover from the exception is to restart the application.

The application must register the IExceptionHandler with StreamLink by setting the ExceptionHandler property of the StreamLink object.

CopyC#
using System;
using System.Collections.Generic;
using System.Text;

using Caplin.StreamLink;
using Caplin.StreamLink.Authentication;

namespace StreamLinkExamples.Basics
{
    /// <summary>
    /// Example inner class that implements IExceptionHandler and
    /// a an outline of how it may be used.
    /// </summary>
    public class SettingUpAnExceptionHandler
    {
        /// <summary>
        /// An example of how to set up a very basic exception handler.
        /// </summary>
        public static void SettingUpAnExceptionHandlerExample()
        {
            // Create a basic StreamLink instance
            StreamLink myStreamLink = new StreamLink();

            // Set up the exception handler
            myStreamLink.ExceptionHandler = new ExampleExceptionHandler();
        }

        /// <summary>
        /// Example class that implements IExceptionHandler
        /// </summary>
        private class ExampleExceptionHandler: IExceptionHandler
        {
            /// <summary>
            /// IExceptionHandler method called when an unexpected exception
            /// occurs within the StreamLink.NET library.
            /// </summary>
            /// <param name="ex">The exception.</param>
            public void HandleException(Exception ex)
            {
                // Clean up application

                // Warn the user about the error and that the application is
                // to close

                // Close the application
            }
        }
    }
}
Thread Safety

The IExceptionHandler methods are not called on a dedicated worker thread. They are called directly from a thread running within the StreamLink.NET library.

Assembly: Caplin.StreamLink (Module: Caplin.StreamLink) Version: 5.0.5.0 (5.0.5.0)