[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2011-02-28
5
Medium Priority
?
920 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 1000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

656 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