How does this simple function hang up?

by eBob.com on 11/1/2007 10:03:00 AM The dirt simple function below hangs up the thread it is executing on.

Private Function PurifyTelnum(ByVal telnum As String) As String

        ' drop trailing " "

        Dim nbspIndex As Integer = telnum.Length - 5 ' offset to " "
if it's at the end of the string
        If telnum.Substring(nbspIndex, 6) = " " Then
            Return telnum.Substring(0, telnum.Length - 6)
        End If

        ' drop imbedded "&nbsp;<br>" and then get rid of redundant blanks

        Return CleanUpIdiomas(telnum.Replace("&nbsp;<br>", " "))

        Return telnum
    End Function

In single-stepping thru the code the last statement highlighted is
   If telnum.Substring(nbspIndex, 6) = "&nbsp;" Then
I see no indication that it gets to the Return statement below it.

When I do a "Break All" and try to look at the thread I get a pop-up saying
that there is no source code corresponding to the location (but it does not
say what source code it is looking for).

TaskManager indicates that the problem is not a CPU loop.

This is driving me nuts! I'll be grateful if one of you guys spots the
problem.

Thanks, Bob


 

Re: How does this simple function hang up? (Update)

by eBob.com on 11/1/2007 10:48:00 AM I put the code below into a separate and trivial application and discovered
right off that the PurifyTelnum function has at least one dumb error -
nbspIndex can be less than 0. This causes a pop-up when the error occurs in
the trivial application. But in my "real" application where this code is
running in its own thread there is no pop-up. Is this because I've done
something wrong in the way I do the multi-threading? Or is it just the way
it is? I hope it's some dumb mistake on my part because it was a real pain
to find the source of the problem without the error pop-up.

Thanks, Bob


"eBob.com" <eBob.com@totallybogus.com> wrote in message
news:%23y9nZFLHIHA.3956@TK2MSFTNGP04.phx.gbl...
> The dirt simple function below hangs up the thread it is executing on.
>
> Private Function PurifyTelnum(ByVal telnum As String) As String
>
> ' drop trailing "&nbsp;"
>
> Dim nbspIndex As Integer = telnum.Length - 5 ' offset to "&nbsp;"
> if it's at the end of the string
> If telnum.Substring(nbspIndex, 6) = "&nbsp;" Then
> Return telnum.Substring(0, telnum.Length - 6)
> End If
>
> ' drop imbedded "&nbsp;<br>" and then get rid of redundant blanks
>
> Return CleanUpIdiomas(telnum.Replace("&nbsp;<br>", " "))
>
> Return telnum
> End Function
>
> In single-stepping thru the code the last statement highlighted is
> If telnum.Substring(nbspIndex, 6) = "&nbsp;" Then
> I see no indication that it gets to the Return statement below it.
>
> When I do a "Break All" and try to look at the thread I get a pop-up
> saying that there is no source code corresponding to the location (but it
> does not say what source code it is looking for).
>
> TaskManager indicates that the problem is not a CPU loop.
>
> This is driving me nuts! I'll be grateful if one of you guys spots the
> problem.
>
> Thanks, Bob
>