using System;
using DotNetBrowser;
using DotNetBrowser.Events;

namespace MyNamespace
    class Program
        static void Main(string[] args)
            // Create Browser instance.
            Browser browser = BrowserFactory.Create();

            // Register custom DownloadHandler implementation.
            browser.DownloadHandler = new MyDownloadHandler();

            // Load URL that initiates file download process.

            // Dispose Browser instance.

        public class MyDownloadHandler : DownloadHandler
            public bool AllowDownload(DownloadItem download)
                // Register Downlow Progress Event listener.
                download.DownloadEvent += delegate(object sender, DownloadEventArgs e)
                    // Download is completed.
                    if (e.Item.Completed)
                        Console.Out.WriteLine("Download is completed!");
                // Allow downloading file.
                return true;


Imports System.Threading
Imports DotNetBrowser
Imports DotNetBrowser.Events

Module MyNamespace
    Sub Main(ByVal args As String())

        Dim waitEvent = New ManualResetEvent(False)
        'Create Browser instance.
        Dim browser As Browser = BrowserFactory.Create()
        'Register custom DownloadHandler implementation.
        browser.DownloadHandler = New MyDownloadHandler(waitEvent)
        'Load URL that initiates file download process.
        'Wait while loading
        'Dispose Browser instance.
    End Sub

    Public Class MyDownloadHandler
        Implements DownloadHandler

        Dim WaitEvent As ManualResetEvent

        Sub New (waitEvent As ManualResetEvent)
            Me.WaitEvent = waitEvent
        End Sub

        Public Function AllowDownload(ByVal download As DownloadItem) As Boolean _
            Implements DownloadHandler.AllowDownload
            'Register Download Progress Event listener.
            AddHandler download.DownloadEvent, sub(ByVal sender As Object, ByVal e As DownloadEventArgs)
                'Download is completed.
                If e.Item.Completed Then
                    Console.Out.WriteLine("Download is completed!")
                End If
            End sub
            'Allow downloading file.
            Return True
        End Function
    End Class
End Module