Solved

How do i refresh a webpage without running the code behind again.

Posted on 2011-02-28
5
918 Views
Last Modified: 2012-05-11
Hi,
I have a webpage that has 5 gridviews on it. In the code behind I have a method that checks the status of an IP address on my network.  The results are then displayed on one of the gridview. The problem is, this method take up to a minute to run so everytime I load the webpage, it takes forever to load.

I then placed this method in a seperate thread so the webpage loads straight away and my method is running on the seperate thread. What I would like is for the method to finish and then update the gridview but I don't want the page to refresh and run the code behind again.

This is the client side code that I'm using to refresh the page
<meta http-equiv="refresh" content="100">

I've tried adding the following in my page load event but the thread seems to be triggered every time.

  If Not Page.IsPostBack Then
            secondThread.Start(pingDataTable)

        End If

Can anyone help me with this or suggest an alternative way I can update my gridview when the method has finished running.

One last thing, If I don't have the thread, my gridview does populate but like I said I have to wait a while before my page is displayed.

Thanks
0
Comment
Question by:Michael Roodt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:sindhuxyz
ID: 34999165
You can control thread like this

Dim thread1 As New Thread(AddressOf yourmethod)
                    thread1.IsBackground = True
                    thread1.Start()

While (thread1.IsAlive )
thread.sleep(200)
end while
0
 
LVL 2

Author Comment

by:Michael Roodt
ID: 34999386
Thanks sindhuxyz but can you explain  what the above does. I'm new to threads but from the above does your code not just make the thread sleep all the time. I need a way of saying when the method is done, update my gridview on the client side but at the same time don't run  the thread again when the update of the gridview takes place.

Thanks
0
 
LVL 5

Accepted Solution

by:
sindhuxyz earned 500 total points
ID: 34999621
the code will start thread with yourmethod and wait until it goes to end(with help of while). After End While, you can refresh your grid or do anything else

Hope, it is clear now.
0
 
LVL 2

Author Comment

by:Michael Roodt
ID: 35005666
With the method above my webpage still only loads once the thread is finished. I  need the page to load but at the same time use the page while the thread is running and when the thread is done. I need to refresh my grid.  How do I manually force the grid to refresh when the thread is finished.

Many thanks
0
 
LVL 2

Author Closing Comment

by:Michael Roodt
ID: 35014727
Didn't really get my my main point of the question answered and have found another solution
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question