Observer

A QuickIO observer is a central contact point and allows the condition monitoring of QuickIO.NET services and QuickIO jobs.
It is possible to create an own observer by inherit from IQuickIOTransferObserver and QuickIOTransferObserver to monitor your own services and jobs at a central point and gather all information.

Another advantage of the QuickIO.NET observer architecture is the simple testing with mock-objects.

Sample for an own observer with custom event


/// <summary>
/// My observer interface
/// </summary>
public interface IMyExampleObserver : IQuickIOTransferObserver
{
    /// <summary>
    /// Description of MyEvent
    /// </summary>
    event MyExampleObserver.MyCustomEventHandler MyEvent;
    /// <summary>
    /// Fire <see cref="MyExampleObserver.MyEvent" />
    /// </summary>
    void OnMyEvent( );
}
/// <summary>
/// my observer implementation
/// </summary>
public class MyExampleObserver : QuickIOTransferObserver, IMyExampleObserver
{
    /// <summary>
    /// Delegate for <see cref="MyEvent" />
    /// </summary>
    public delegate void MyCustomEventHandler( object sender, EventArgs e );
    /// <summary>
    /// Description of MyEvent
    /// </summary>
    public event MyCustomEventHandler MyEvent;
    /// <summary>
    /// Fire <see cref="MyEvent" />
    /// </summary>
    public virtual void OnMyEvent( )
    {
        if ( MyEvent != null )
        {
            MyEvent( this, EventArgs.Empty );
        }
    }
    /// <summary>
    /// For example we want to log each worker creation, but  the keep the default behavior
    /// </summary>
    public override void OnWorkerCreated( QuickIOTransferWorkerCreatedEventArgs args )
    {
        base.OnWorkerCreated( args );
        QuickIOFile.AppendAllText( "Log_WorkerCreation.log", String.Format( "[{0}] NEW WORKER: {1} ", DateTime.Now, args.WorkerID ) );
    }
}
/// <summary>
/// Example usage of own observer
/// </summary>
public class Program
{
    /// <summary>
    /// Program implementation
    /// </summary>
    public static void OwnObserverExample( )
    {
        var myObserver = new MyExampleObserver( );
        var service1 = new QuickIOTransferBackgroundService( myObserver, workerCount: 1 );
        var service2 = new QuickIOTransferBackgroundService( myObserver, workerCount: 4 );
        var directoryCopyService = new QuickIOTransferDirectoryCopyService( myObserver, new QuickIODirectoryInfo( @"C:\temp" ), @"C:\temp_testtarget" );
        // service usage here
    }
}