Monitoring a Web Page request Thread?

  • Thread starter Thread starter Elizabeth Harmon
  • Start date Start date
E

Elizabeth Harmon

hi All,

I dont know if this is possible, so i am asking

Is there a Way to monitor a connection when it is fetching on a web page? I
am providing a status Bar and process to my users so they can see something
is happening?

I would like to do a while loop as in

i+=1
Do while ConnectionState.Fetching
WriteStatusUpdate(writer, "Fetching Records ..." & i.toString(), true)
i+=1
loop
I am currently using the Protected OverRide Render writer to show status,
and would like a little more detail?

Any Suggestions Grealt Appreciated, If you need to review the code, while
lenghty, may help some one else. Code as Follows:

thanks in advance
Smantha

Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

Dim strmsg As String = ""

' Call the parent render and then flush the contents to get them to the
browser quickly

MyBase.Render(writer)

writer.Flush()

Response.Flush()

' Check to see if btnClear was clicked and that's why we're rendering

If boolStartEvent Then



' Send a "starting operation" message

WriteStatusUpdate(writer, "Checking Connection ...", False)

' Do your long running operation here - provide status at will

Dim TimerEnd As Long = Now().Ticks + 100000000

While Now().Ticks <= TimerEnd

End While

If IsPostBack Then

strmsg = checkConnection()

End If

If blnConnectFound = True Then

WriteStatusUpdate(writer, "Found. Proceeding With Update,Please Wait.",
True)

writer.Flush()

Response.Flush()

chkConn = New SqlConnection

chkConn.ConnectionString = ConfigurationSettings.AppSettings("SqlServer")

Try

chkConn.Open()

cmdSql.Connection = chkConn

cmdSql.CommandType = CommandType.StoredProcedure

cmdSql.CommandText = "csp_INSERT_Get_Member_Info"

cmdSql.ExecuteNonQuery()

*************************************************

Would like to Monitor thread here if Possible?

*************************************************



chkConn.Close()

chkConn.Dispose()

chkConn = Nothing

cmdSql = Nothing

WriteStatusUpdate(writer, "Update Completed. Please Click Find a Patient.",
True)

writer.Flush()

Response.Flush()

Exit Sub

Catch ex As Exception

WriteStatusUpdate(writer, "Connection to DB not Available because." & "<BR>"
& ex.Message, True)

writer.Flush()

Response.Flush()

chkConn.Close()

chkConn.Dispose()

chkConn = Nothing

cmdSql = Nothing

End Try





End If

statBar.Style.Clear()

statBar.Style.Add("display", "none")

Response.Flush()

' Clear flag

boolStartEvent = False

Response.Flush()





End If

End Sub



Private Sub WriteStatusUpdate(ByVal writer As System.Web.UI.HtmlTextWriter,
ByVal Status As String, ByVal NewLine As Boolean)

If NewLine Then

writer.Write _

(String.Format("<script
language=""javascript"">document.all[""updatingGif""].innerHTML +=
""{0}<br>"";</script>", Status))

Else

writer.Write _

(String.Format("<script
language=""javascript"">document.all[""updatingGif""].innerHTML +=
""{0}"";</script>", Status))

End If

writer.Flush()

Response.Flush()

End Sub
 
This will not work because the flushing to the browser only occurs after the
main thread is processing. You will not see any incremental updates.

To create a status bar, you need to do so on a separate thread. While one
thread does work, the other thread updates the user interface. About the
easiest thing you can do to get this to work if you don't want to thread is
to cause the page to refresh itself with a meta refresh tag every so often.
At this refresh time, you will update your status bar appropriately.

Regards

--


-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
Elizabeth Harmon said:
hi All,

I dont know if this is possible, so i am asking

Is there a Way to monitor a connection when it is fetching on a web page? I
am providing a status Bar and process to my users so they can see something
is happening?

I would like to do a while loop as in

i+=1
Do while ConnectionState.Fetching
WriteStatusUpdate(writer, "Fetching Records ..." & i.toString(), true)
i+=1
loop
I am currently using the Protected OverRide Render writer to show status,
and would like a little more detail?

Any Suggestions Grealt Appreciated, If you need to review the code, while
lenghty, may help some one else. Code as Follows:

thanks in advance
Smantha

Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

Dim strmsg As String = ""

' Call the parent render and then flush the contents to get them to the
browser quickly

MyBase.Render(writer)

writer.Flush()

Response.Flush()

' Check to see if btnClear was clicked and that's why we're rendering

If boolStartEvent Then



' Send a "starting operation" message

WriteStatusUpdate(writer, "Checking Connection ...", False)

' Do your long running operation here - provide status at will

Dim TimerEnd As Long = Now().Ticks + 100000000

While Now().Ticks <= TimerEnd

End While

If IsPostBack Then

strmsg = checkConnection()

End If

If blnConnectFound = True Then

WriteStatusUpdate(writer, "Found. Proceeding With Update,Please Wait.",
True)

writer.Flush()

Response.Flush()

chkConn = New SqlConnection

chkConn.ConnectionString = ConfigurationSettings.AppSettings("SqlServer")

Try

chkConn.Open()

cmdSql.Connection = chkConn

cmdSql.CommandType = CommandType.StoredProcedure

cmdSql.CommandText = "csp_INSERT_Get_Member_Info"

cmdSql.ExecuteNonQuery()

*************************************************

Would like to Monitor thread here if Possible?

*************************************************



chkConn.Close()

chkConn.Dispose()

chkConn = Nothing

cmdSql = Nothing

WriteStatusUpdate(writer, "Update Completed. Please Click Find a Patient.",
True)

writer.Flush()

Response.Flush()

Exit Sub

Catch ex As Exception

WriteStatusUpdate(writer, "Connection to DB not Available because." &
& ex.Message, True)

writer.Flush()

Response.Flush()

chkConn.Close()

chkConn.Dispose()

chkConn = Nothing

cmdSql = Nothing

End Try





End If

statBar.Style.Clear()

statBar.Style.Add("display", "none")

Response.Flush()

' Clear flag

boolStartEvent = False

Response.Flush()





End If

End Sub



Private Sub WriteStatusUpdate(ByVal writer As System.Web.UI.HtmlTextWriter,
ByVal Status As String, ByVal NewLine As Boolean)

If NewLine Then

writer.Write _

(String.Format("<script
language=""javascript"">document.all[""updatingGif""].innerHTML +=
""{0}<br>"";</script>", Status))

Else

writer.Write _

(String.Format("<script
language=""javascript"">document.all[""updatingGif""].innerHTML +=
""{0}"";</script>", Status))

End If

writer.Flush()

Response.Flush()

End Sub
 
Is there an Example of this some where?

thanks in advance
Samantha
Alvin Bruney said:
This will not work because the flushing to the browser only occurs after the
main thread is processing. You will not see any incremental updates.

To create a status bar, you need to do so on a separate thread. While one
thread does work, the other thread updates the user interface. About the
easiest thing you can do to get this to work if you don't want to thread is
to cause the page to refresh itself with a meta refresh tag every so often.
At this refresh time, you will update your status bar appropriately.

Regards

--


-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
Elizabeth Harmon said:
hi All,

I dont know if this is possible, so i am asking

Is there a Way to monitor a connection when it is fetching on a web
page?
I
am providing a status Bar and process to my users so they can see something
is happening?

I would like to do a while loop as in

i+=1
Do while ConnectionState.Fetching
WriteStatusUpdate(writer, "Fetching Records ..." & i.toString(), true)
i+=1
loop
I am currently using the Protected OverRide Render writer to show status,
and would like a little more detail?

Any Suggestions Grealt Appreciated, If you need to review the code, while
lenghty, may help some one else. Code as Follows:

thanks in advance
Smantha

Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

Dim strmsg As String = ""

' Call the parent render and then flush the contents to get them to the
browser quickly

MyBase.Render(writer)

writer.Flush()

Response.Flush()

' Check to see if btnClear was clicked and that's why we're rendering

If boolStartEvent Then



' Send a "starting operation" message

WriteStatusUpdate(writer, "Checking Connection ...", False)

' Do your long running operation here - provide status at will

Dim TimerEnd As Long = Now().Ticks + 100000000

While Now().Ticks <= TimerEnd

End While

If IsPostBack Then

strmsg = checkConnection()

End If

If blnConnectFound = True Then

WriteStatusUpdate(writer, "Found. Proceeding With Update,Please Wait.",
True)

writer.Flush()

Response.Flush()

chkConn = New SqlConnection

chkConn.ConnectionString = ConfigurationSettings.AppSettings("SqlServer")

Try

chkConn.Open()

cmdSql.Connection = chkConn

cmdSql.CommandType = CommandType.StoredProcedure

cmdSql.CommandText = "csp_INSERT_Get_Member_Info"

cmdSql.ExecuteNonQuery()

*************************************************

Would like to Monitor thread here if Possible?

*************************************************



chkConn.Close()

chkConn.Dispose()

chkConn = Nothing

cmdSql = Nothing

WriteStatusUpdate(writer, "Update Completed. Please Click Find a Patient.",
True)

writer.Flush()

Response.Flush()

Exit Sub

Catch ex As Exception

WriteStatusUpdate(writer, "Connection to DB not Available because." &
& ex.Message, True)

writer.Flush()

Response.Flush()

chkConn.Close()

chkConn.Dispose()

chkConn = Nothing

cmdSql = Nothing

End Try





End If

statBar.Style.Clear()

statBar.Style.Add("display", "none")

Response.Flush()

' Clear flag

boolStartEvent = False

Response.Flush()





End If

End Sub



Private Sub WriteStatusUpdate(ByVal writer As System.Web.UI.HtmlTextWriter,
ByVal Status As String, ByVal NewLine As Boolean)

If NewLine Then

writer.Write _

(String.Format("<script
language=""javascript"">document.all[""updatingGif""].innerHTML +=
""{0}<br>"";</script>", Status))

Else

writer.Write _

(String.Format("<script
language=""javascript"">document.all[""updatingGif""].innerHTML +=
""{0}"";</script>", Status))

End If

writer.Flush()

Response.Flush()

End Sub
 
Did you figure this out or get help on this?

--
Regards,
Alvin Bruney
Got Tidbits? Get it here
www.networkip.net/tidbits
Elizabeth Harmon said:
Is there an Example of this some where?

thanks in advance
Samantha
Alvin Bruney said:
This will not work because the flushing to the browser only occurs after the
main thread is processing. You will not see any incremental updates.

To create a status bar, you need to do so on a separate thread. While one
thread does work, the other thread updates the user interface. About the
easiest thing you can do to get this to work if you don't want to thread is
to cause the page to refresh itself with a meta refresh tag every so often.
At this refresh time, you will update your status bar appropriately.

Regards

--


-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
Elizabeth Harmon said:
hi All,

I dont know if this is possible, so i am asking

Is there a Way to monitor a connection when it is fetching on a web
page?
I
am providing a status Bar and process to my users so they can see something
is happening?

I would like to do a while loop as in

i+=1
Do while ConnectionState.Fetching
WriteStatusUpdate(writer, "Fetching Records ..." & i.toString(), true)
i+=1
loop
I am currently using the Protected OverRide Render writer to show status,
and would like a little more detail?

Any Suggestions Grealt Appreciated, If you need to review the code, while
lenghty, may help some one else. Code as Follows:

thanks in advance
Smantha

Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

Dim strmsg As String = ""

' Call the parent render and then flush the contents to get them to the
browser quickly

MyBase.Render(writer)

writer.Flush()

Response.Flush()

' Check to see if btnClear was clicked and that's why we're rendering

If boolStartEvent Then



' Send a "starting operation" message

WriteStatusUpdate(writer, "Checking Connection ...", False)

' Do your long running operation here - provide status at will

Dim TimerEnd As Long = Now().Ticks + 100000000

While Now().Ticks <= TimerEnd

End While

If IsPostBack Then

strmsg = checkConnection()

End If

If blnConnectFound = True Then

WriteStatusUpdate(writer, "Found. Proceeding With Update,Please Wait.",
True)

writer.Flush()

Response.Flush()

chkConn = New SqlConnection

chkConn.ConnectionString = ConfigurationSettings.AppSettings("SqlServer")

Try

chkConn.Open()

cmdSql.Connection = chkConn

cmdSql.CommandType = CommandType.StoredProcedure

cmdSql.CommandText = "csp_INSERT_Get_Member_Info"

cmdSql.ExecuteNonQuery()

*************************************************

Would like to Monitor thread here if Possible?

*************************************************



chkConn.Close()

chkConn.Dispose()

chkConn = Nothing

cmdSql = Nothing

WriteStatusUpdate(writer, "Update Completed. Please Click Find a Patient.",
True)

writer.Flush()

Response.Flush()

Exit Sub

Catch ex As Exception

WriteStatusUpdate(writer, "Connection to DB not Available because." &
& ex.Message, True)

writer.Flush()

Response.Flush()

chkConn.Close()

chkConn.Dispose()

chkConn = Nothing

cmdSql = Nothing

End Try





End If

statBar.Style.Clear()

statBar.Style.Add("display", "none")

Response.Flush()

' Clear flag

boolStartEvent = False

Response.Flush()





End If

End Sub



Private Sub WriteStatusUpdate(ByVal writer As System.Web.UI.HtmlTextWriter,
ByVal Status As String, ByVal NewLine As Boolean)

If NewLine Then

writer.Write _

(String.Format("<script
language=""javascript"">document.all[""updatingGif""].innerHTML +=
""{0}<br>"";</script>", Status))

Else

writer.Write _

(String.Format("<script
language=""javascript"">document.all[""updatingGif""].innerHTML +=
""{0}"";</script>", Status))

End If

writer.Flush()

Response.Flush()

End Sub
 
Back
Top