Potential Loop

  • Thread starter Thread starter tascien
  • Start date Start date
T

tascien

Please look at the code below:

Would this code cause an infinite loop at any logic?

Sub Page_Load( sender , e ) handles Mybase.Load

sw = new StringWriter
hw = new HtmlTextWriter(sw)
MyBase.Render(hw) '<-- would this code call this sub again,
'thus causing infinite loop?
hw.close

debug.print sw.ToString()

end Sub
 
Not a VB expert but there is no condition that this could cause an
infinite loop ...

The code behind this is the following (from reflector)

Protected Overridable Sub Render(ByVal writer As HtmlTextWriter)
Me.RenderChildren(writer)
End Sub

Protected Overridable Sub RenderChildren(ByVal writer As
HtmlTextWriter)
If (Not Me._renderMethod Is Nothing) Then
Me._renderMethod.Invoke(writer, Me)
Else
If (Not Me._controls Is Nothing) Then
Dim num1 As Integer = Me._controls.Count
Dim num2 As Integer
For num2 = 0 To num1 - 1
Me._controls.Item(num2).RenderControl(writer)
Next num2
End If
End If
End Sub

Public Sub RenderControl(ByVal writer As HtmlTextWriter)
If Not Me.flags.Item(16) Then
Dim context1 As HttpContext = IIf((Me._page Is Nothing),
Nothing, Me._page._context)
If ((Not context1 Is Nothing) AndAlso
context1.TraceIsEnabled) Then
Dim num1 As Integer =
context1.Response.GetBufferedLength
Me.Render(writer)
Dim num2 As Integer =
context1.Response.GetBufferedLength
context1.Trace.AddControlSize(Me.UniqueID, (num2 -
num1))
Else
Me.Render(writer)
End If
End If
End Sub
 
Back
Top