Solved

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

Posted on 2011-02-28
5
915 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
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:sindhuxyz
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Didn't really get my my main point of the question answered and have found another solution
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now