DCSIMG
August 2009 - Posts - Pini Dayan

Pini Dayan

The best thing about a boolean is even if you are wrong, you are only off by a bit.

August 2009 - Posts

Monitoring your application – real-time

Wouldn’t it be nice if we could monitor our application while it is actually running? And by monitoring i mean watching what is happening , which method is being called right now and what are the arguments it has?

Apparently we can. All we need to do is write code that writes to a log file with any library we wish. We can use Enterprise library Logging application block or log4net (Or build something of our own).

When our application is running the log file is being appended with the new data. but we cant see what is being written there in real time. so , here is a nice cool tool that does exactly that : it watches the appended text, let you filter what ever you want no matter what the format line is and let you even color important words you wish to see.

It is called “WinTail” and can be downloaded from here.

Here is a snap shot of what it can do:

ScrShot

Enjoy.

Posted: Aug 27 2009, 09:26 AM by Pini Dayan | with 1 comment(s) |
תגים:

Handling ASP.NET Async pages client disconnection

Lately I have been working a lot with ASP.NET amazing feature :Asynchronous  pages. Whenever the page has a lot of work in the server and he wishes to set free the thread handling this request, this is the time we need to use Async pages.

I will not go into details about what Async pages are, but in a nutshell: Since there is a limit to the thread ASP.NET can use , we wish to free the long bounded thread to other thread so that they will not wait. (A good example can be: a page calling web service or doing IO work)

Now what is the operation the BeginProcessRequest does is very long, how do we know that the client is still connected and we need to send him back the response?

In addition to Async pages we can even write an HTTPHandler that is Async and will show one to illustate the problem:

   public class CallMeAsyncHandler : IHttpAsyncHandler

   {

         private HttpContext oCurrent;

         public void ProcessRequest(HttpContext context){}

 

         public bool IsReusable

         {

             get

             {

                 return false;

             }

         }

 

   public IAsyncResult BeginProcessRequest

                  (HttpContext context, AsyncCallback cb, object extraData)

   {

     //Do some log operation here

     //Create some IAsync result and return it

     return oAsync;

   }

 

   public void EndProcessRequest(IAsyncResult oAsyncResult)

   {

       //Write back to the output (Response object for instance)

   }

The answer is very simple,as it turns out the Response object has a property specifying the client is still connected : Response.IsClientConnected.

Hope this helps, enjoy.

Advanced JavaScript Open House

Hi all, As I promised, I am uploading the presentation and source files from the Open day at Sela this week.

In these files you can see the source code of the samples we showed in class and the slides which are a good reference to the highlight of this day. Than you all for participating...

Download