I have a script task which downloads a file using a HTTP connection object. This script task is part of a package which is called by another package. Sometimes the connection cannot be established. In these instances I want to retry the connection a number of times before finally raising an error if the connection attempts fail.

I tried to implement this. It appeared to work and the task does not fail. However an OnError event is still propagated every time an exception happens in the script task even though the script task doesn't fail. The fail occurs once control is passed from the child package back to the parent package.

```
Public Sub Main()
Dim tryTimes As Integer = 0 
Dim maxTimes As Integer = 4 
While (True) 
    Try
        Dim nativeObject As Object = Dts.Connections("HTTP Connection Manager").AcquireConnection(Nothing)
            'Create a new HTTP client connection
        Dim connection As New HttpClientConnection(nativeObject)
        Dim filename As String = Dts.Variables("Working_File").Value
        connection.DownloadFile(filename, True)
        Dts.TaskResult = ScriptResults.Success
        Exit While
    Catch ex As Exception
        If (tryTimes < maxTimes) Then
            tryTimes = tryTimes + 1
            Thread.Sleep(30000) 
        Else 
            MsgBox(ex.Message)
            Dts.TaskResult = ScriptResults.Failure
            Throw
        End If
    End Try
End While
End Sub

```

I am hoping to get a solution where the OnError event is not called unless the connection attempts fails a certain number of times.