Implementing Timer and Counter of Loaded Strings on Web Form

Total: 0 Average: 0

During the development of reporting forms, a user wanted to see the process of data loading from the database. He wanted the timer to start running after hitting the button, and as strings were received, their number was displayed on the form. I needed to implement this within an existing ASP.NET project.

When I was solving this task, I needed to select a system for data transfer with the server. It must receive data and a certain response without the page reload. Besides the dramatic rewrite of everything on MVC, there are other methods. For instance, we can use the callback controls from DevExpress or similar commercial solutions. In this particular case, I chose HTTPHandler. Its benefit is a minimum of code that is executed by the server in comparison with other methods. Thus, the performance of the method is quite high, unlike ASP.NET applications. On the client side, I used JQuery and the setTimeout function.

On the server side, the code looks as follows:

The TestForm.aspx.cs file
HTTPHandler for the text — HTTPHandlerTest.ashx.cs :
On the client side, we need to add a couple of strings:

The TestForm.aspx file

The skHTTPHandler.js file:

During the development, a memory leak on the client side revealed itself. I solved it with the following code:

I found this solution in the post: Memory Growing to Heaven.


During the work with ASP.NET, we had to shift toward the thick client and use the server as a data source. HTTPHandler does a great job and allows storing ASP.NET-specific functionality and bypass its cons.


This solution also helped me to track bugs related to the DB Oracle provider. From time to time, when I’m getting data from a server, the speed of string read began to drop quickly. I managed to fix it with assigning value 23 to Min Pool Size and Max Pool Size.


Alexander Korolev

Alexander graduated in computer science, and later in accounting. He has been working as a software developer since 2000: started as a C ++ developer, worked with .NET for a long time, parallelly working with databases (DWH, Business Intelligence, OLAP). Alexander has experience with Java technologies.
Alexander Korolev