Console Cancel Key Press (CONTROL+C/Break)

AddHandler Console.CancelKeyPress, AddressOf myCtronCHandler

    Sub myCtronCHandler (ByVal sender As Object,

                                 ByVal args As ConsoleCancelEventArgs)


        'debug.print(vbCrLf & "The read operation has been interrupted.")

        'debug.print("  Key pressed: {0}", args.SpecialKey)

        'debug.print("  Cancel property: {0}", args.Cancel)

        '' Set the Cancel property to true to prevent the process from terminating.

        'debug.print("Setting the Cancel property to true...")

        'args.Cancel = True

        '' Announce the new value of the Cancel property.

        'debug.print("  Cancel property: {0}", args.Cancel)

        'debug.print("The read operation will resume..." & vbCrLf)

    End Sub