"Please give me some suggestions on how to implement the above functionality."If I'm understanding you correctly, it sounds like you're refreshing the page every second for display purposes, and you're doing a read on every web request. It seems like it would be preferable to decouple these two actions.
One approach would be to create a separate application or a Windows service that's doing the reading and writing. This app/service could be running continuously and could read on whatever interval you like, rather than having the interval tied to how fast a web page can refresh and having the reads occurring during the web request. You could then log this data to a database, file, memory buffer, etc. This app/service could then expose a remoting interface so that you can communicate with it from the outside. In this example, there could be a Write method exposed on the remoting interface.
Once you have the app/service in place, the ASP.NET part becomes a remote front end to the app/service. You could make the interval whatever you like because the reading interval is determined by the app/service - the ASP.NET part would read the data from the database/file/memory buffer/etc. that the app/service is writing to and display it. When the browser sends data, the ASP.NET application could call the Write method that's exposed through the remoting interface, and then continue displaying the data. The app/service would handle the write, and then continue reading when it's done.
"Are there any tips and tricks to display the data smoothly?"Maybe, depending on what your user interface looks like. If you go with the approach above, you may be able to make the interval longer since the app/service is reading every second and you're no longer relying on a web request every second in order for the read to happen. Another option would be to expose some functionality through a web service to send and receive data, and then use the
WebService behavior to send and receive from the client, then use client-side script to update your interface. ASP.NET 2.0 has a new feature called script callbacks (also sometimes referred to as async callbacks and out-of-band callbacks). This was an article about this in a recent
MSDN magazine called
Script Callbacks in ASP.NET. At the end of the article there's an example of how you could implement similar functionality in ASP.NET 1.0/1.1.
Hope this helps.
- Elton