Exemple #1
0
 void HandleRequest(System.Net.HttpListenerContext ctx)
 {
     try
     {
         var outStream = new System.IO.MemoryStream(0x1000);
         var wrs       = new WebResultSet(ctx, outStream);
         var stopWatch = new System.Diagnostics.Stopwatch();
         stopWatch.Start();
         lock (Database) Database.Sql("EXEC web.Main()", wrs);
         stopWatch.Stop();
         System.Console.WriteLine("Time (ms)=" + stopWatch.ElapsedTicks / (System.Diagnostics.Stopwatch.Frequency / 1E3));
         wrs.SendEmails();
         try
         {
             outStream.Position = 0;
             outStream.CopyTo(ctx.Response.OutputStream);
         } catch (System.Exception) {} // Exceptions due to client closing connection etc. are normal.
     }
     catch (System.Exception e) { System.Console.WriteLine("Exception: " + e); }
     finally { ctx.Response.OutputStream.Close(); }
 }
 void HandleRequest(System.Net.HttpListenerContext ctx)
 {
     try
     {
         var outStream = new System.IO.MemoryStream();
         var wrs       = new WebResultSet(ctx, outStream);
         //var stopWatch = new System.Diagnostics.Stopwatch();
         //stopWatch.Start();
         lock (Database) Database.Sql("EXEC web.Main()", wrs);
         //stopWatch.Stop();
         //System.Console.WriteLine( "Time (ticks)=" + stopWatch.ElapsedTicks + " ticks per ms="  + System.Diagnostics.Stopwatch.Frequency/1000 );
         outStream.Position = 0;
         outStream.CopyTo(ctx.Response.OutputStream);
     }
     catch (System.Exception e)
     {
         System.Console.WriteLine("Handle Request Exception: " + e);
     }
     finally
     {
         ctx.Response.OutputStream.Close();
     }
 }