How does this simple function hang up?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • eBob.com

    How does this simple function hang up?

    The dirt simple function below hangs up the thread it is executing on.

    Private Function PurifyTelnum(By Val 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.Substrin g(nbspIndex, 6) = " " Then
    Return telnum.Substrin g(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.Substrin g(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


  • eBob.com

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

    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@total lybogus.comwrot e in message
    news:%23y9nZFLH IHA.3956@TK2MSF TNGP04.phx.gbl. ..
    The dirt simple function below hangs up the thread it is executing on.
    >
    Private Function PurifyTelnum(By Val 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.Substrin g(nbspIndex, 6) = "&nbsp;" Then
    Return telnum.Substrin g(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.Substrin g(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
    >

    Comment

    Working...