multi threading and AJAX


B

Bruno Alexandre

Hi guys,

I have this page that needs to be populated with 2 diferent web services,
and each one takes more or less 10 seconds to finish populate his own part,
so I move on to the multi threading inside ASP.NET.

my questions is:

having a ASP.NET AJAX page and my gridView inside an atlas:UpdatePanel
control how can I update the panel so it shows the datagrid with the results
from the webservice?

Sub callDRService()
Dim dr As New drService
dr.getDRInfoFromWebService("John", "Hansen", "Nørregade 86", "5700",
False)
gvDRWarnings.DataSource = dr.warningTable
gvDRWarnings.DataBind()
up.Update()
End Sub

the up control is a UpdatePanel, but at the end of the thread the panel
simple wont update :-(

any thoughts?


code for page_load and thread call
-------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
populateDRFromWService_Thread()
End Sub
Public Sub populateDRFromWService_Thread()
Dim NewThread As Thread = New Thread(AddressOf callDRService)
NewThread.Priority = ThreadPriority.Lowest
NewThread.Start()
End Sub
-------------------------
--

Bruno Alexandre
København, Danmark

"a portuguese in Denmark"
 
Ad

Advertisements

A

Alvin Bruney [MVP]

Interesting. This is probably not related to AJAX though. It probably is
related to the timing of the thread and the update call. Wrap your bind code
in a null check to make sure data is back before you call the update. That
will eliminate or confirm the timing issue.

if(dr.warningTable IsNotNull And dr.warningTable[0].rows.count > 0) then
gvDRWarnings.DataSource = dr.warningTable
gvDRWarnings.DataBind()
up.Update()
end if

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
 
B

Bruno Alexandre

the problem remains...
after the page is completed, I can't update anything on it. even an
UpdatePanel :-(

what I did was wait for the 2 threads to finish and then show the page.
with MultiThreading I get the page shows up in aprox 4sec instead of the
9/12 sec before

not what I was searching in the first place - I want to present the page and
a progress bar saying that the webservice call is still running and when it
finish populate the gridview with all the info. but, I coudn't do that
yet... :-(



--

Bruno Alexandre
København, Danmark

"a Portuguese in Denmark"

Blog. http://balexandre.blogspot.com/
Photos. http://www.flickr.com/photos/balexandre/


Alvin Bruney said:
Interesting. This is probably not related to AJAX though. It probably is
related to the timing of the thread and the update call. Wrap your bind
code in a null check to make sure data is back before you call the update.
That will eliminate or confirm the timing issue.

if(dr.warningTable IsNotNull And dr.warningTable[0].rows.count > 0) then
gvDRWarnings.DataSource = dr.warningTable
gvDRWarnings.DataBind()
up.Update()
end if

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


Bruno Alexandre said:
Hi guys,

I have this page that needs to be populated with 2 diferent web services,
and each one takes more or less 10 seconds to finish populate his own
part, so I move on to the multi threading inside ASP.NET.

my questions is:

having a ASP.NET AJAX page and my gridView inside an atlas:UpdatePanel
control how can I update the panel so it shows the datagrid with the
results from the webservice?

Sub callDRService()
Dim dr As New drService
dr.getDRInfoFromWebService("John", "Hansen", "Nørregade 86", "5700",
False)
gvDRWarnings.DataSource = dr.warningTable
gvDRWarnings.DataBind()
up.Update()
End Sub

the up control is a UpdatePanel, but at the end of the thread the panel
simple wont update :-(

any thoughts?


code for page_load and thread call
-------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
populateDRFromWService_Thread()
End Sub
Public Sub populateDRFromWService_Thread()
Dim NewThread As Thread = New Thread(AddressOf callDRService)
NewThread.Priority = ThreadPriority.Lowest
NewThread.Start()
End Sub
-------------------------
--

Bruno Alexandre
København, Danmark

"a portuguese in Denmark"
 
A

Alvin Bruney [MVP]

post a short but complete program that demonstrates the problem. Short but
complete programs are defined here:
http://www.yoda.arachsys.com/csharp/complete.html

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


Bruno Alexandre said:
the problem remains...
after the page is completed, I can't update anything on it. even an
UpdatePanel :-(

what I did was wait for the 2 threads to finish and then show the page.
with MultiThreading I get the page shows up in aprox 4sec instead of the
9/12 sec before

not what I was searching in the first place - I want to present the page
and a progress bar saying that the webservice call is still running and
when it finish populate the gridview with all the info. but, I coudn't do
that yet... :-(



--

Bruno Alexandre
København, Danmark

"a Portuguese in Denmark"

Blog. http://balexandre.blogspot.com/
Photos. http://www.flickr.com/photos/balexandre/


Alvin Bruney said:
Interesting. This is probably not related to AJAX though. It probably is
related to the timing of the thread and the update call. Wrap your bind
code in a null check to make sure data is back before you call the
update. That will eliminate or confirm the timing issue.

if(dr.warningTable IsNotNull And dr.warningTable[0].rows.count > 0) then
gvDRWarnings.DataSource = dr.warningTable
gvDRWarnings.DataBind()
up.Update()
end if

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


Bruno Alexandre said:
Hi guys,

I have this page that needs to be populated with 2 diferent web
services, and each one takes more or less 10 seconds to finish populate
his own part, so I move on to the multi threading inside ASP.NET.

my questions is:

having a ASP.NET AJAX page and my gridView inside an atlas:UpdatePanel
control how can I update the panel so it shows the datagrid with the
results from the webservice?

Sub callDRService()
Dim dr As New drService
dr.getDRInfoFromWebService("John", "Hansen", "Nørregade 86", "5700",
False)
gvDRWarnings.DataSource = dr.warningTable
gvDRWarnings.DataBind()
up.Update()
End Sub

the up control is a UpdatePanel, but at the end of the thread the panel
simple wont update :-(

any thoughts?


code for page_load and thread call
-------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
populateDRFromWService_Thread()
End Sub
Public Sub populateDRFromWService_Thread()
Dim NewThread As Thread = New Thread(AddressOf callDRService)
NewThread.Priority = ThreadPriority.Lowest
NewThread.Start()
End Sub
-------------------------
--

Bruno Alexandre
København, Danmark

"a portuguese in Denmark"
 
Ad

Advertisements

B

Bruno Alexandre

this can't be for me right?
I gave the code, you gave me a response, and then I told what exactly I did
to get arround my problem!

maybe you just miss it.

--

Bruno Alexandre
København, Danmark

"a Portuguese in Denmark"

Blog. http://balexandre.blogspot.com/
Photos. http://www.flickr.com/photos/balexandre/


Alvin Bruney said:
post a short but complete program that demonstrates the problem. Short but
complete programs are defined here:
http://www.yoda.arachsys.com/csharp/complete.html

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


Bruno Alexandre said:
the problem remains...
after the page is completed, I can't update anything on it. even an
UpdatePanel :-(

what I did was wait for the 2 threads to finish and then show the page.
with MultiThreading I get the page shows up in aprox 4sec instead of the
9/12 sec before

not what I was searching in the first place - I want to present the page
and a progress bar saying that the webservice call is still running and
when it finish populate the gridview with all the info. but, I coudn't do
that yet... :-(



--

Bruno Alexandre
København, Danmark

"a Portuguese in Denmark"

Blog. http://balexandre.blogspot.com/
Photos. http://www.flickr.com/photos/balexandre/


Alvin Bruney said:
Interesting. This is probably not related to AJAX though. It probably is
related to the timing of the thread and the update call. Wrap your bind
code in a null check to make sure data is back before you call the
update. That will eliminate or confirm the timing issue.

if(dr.warningTable IsNotNull And dr.warningTable[0].rows.count > 0) then
gvDRWarnings.DataSource = dr.warningTable
gvDRWarnings.DataBind()
up.Update()
end if

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


Hi guys,

I have this page that needs to be populated with 2 diferent web
services, and each one takes more or less 10 seconds to finish populate
his own part, so I move on to the multi threading inside ASP.NET.

my questions is:

having a ASP.NET AJAX page and my gridView inside an atlas:UpdatePanel
control how can I update the panel so it shows the datagrid with the
results from the webservice?

Sub callDRService()
Dim dr As New drService
dr.getDRInfoFromWebService("John", "Hansen", "Nørregade 86", "5700",
False)
gvDRWarnings.DataSource = dr.warningTable
gvDRWarnings.DataBind()
up.Update()
End Sub

the up control is a UpdatePanel, but at the end of the thread the panel
simple wont update :-(

any thoughts?


code for page_load and thread call
-------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
populateDRFromWService_Thread()
End Sub
Public Sub populateDRFromWService_Thread()
Dim NewThread As Thread = New Thread(AddressOf callDRService)
NewThread.Priority = ThreadPriority.Lowest
NewThread.Start()
End Sub
-------------------------
--

Bruno Alexandre
København, Danmark

"a portuguese in Denmark"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top