Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

ALE - Another Looping Event - (Alpha)

Created by Ben Lesh

Licensed under MIT license


DO NOT USE: This is an old experiment and is not maintained

This project is a Node.js style implementation of an event loop architecture in C#. This is something I whipped up for fun, mostly as a proof of concept. I like it though, and I'm looking for feedback.

Thank you for any feedback you might have.


To start a webserver:

    EventLoop.Start(() => {
		   .Use((req, res) => {
              res.Write("<h1>Hello World</h1>");

To set up a web sockets server:

    EventLoop.Start(() => {
        Net.CreateServer((socket) => {
            socket.Receive((text) => {
                socket.Send("Echo: " + text);
        }).Listen("", 1338, "");

Or just to do something like read a file from disk:

    EventLoop.Start(() => {
        File.ReadAllText(@"C:\File.txt", (text) => {

To start a ALE in IIS:

  • Start a new web project.
  • Reference ALE and ALE.Web.
  • Add a reference to the HttpHandler in the Web.Config (here is the minimum Web.config required):
        <?xml version="1.0"?>
            <compilation debug="true" targetFramework="4.0" />
       	 <validation validateIntegratedModeConfiguration="false"/>
         	<modules runAllManagedModulesForAllRequests="true"/>
         	  <add verb="*" path="*"
  • Add initialization code to Application_Start in your Global.asax:
         void Application_Start(object sender, EventArgs e)
            // Start the event loop.
            // Get the ALE server instance and wire up your middlware.
                .Use((req, res) => res.Write("Hello World"))
                .Use((req, res) => res.Write("<br/>No seriously, I said hello."));
  • Add teardown in Application_End in your Global.asax:
         void Application_End(object sender, EventArgs e)
             // Shut down the EventLoop.

See my related blog posts for more information:

Version History

  • v - Added basic Promise implementation
  • v - Updated EventLoops to be slightly more efficient.
    • added unit tests.
    • Fixed issues with Razor templating.
    • Fixed some issues with routing.
  • v - Added FileSystemWatcher implemention.
    • added beginnings of Razor template view processor.
  • v - Added routing.
  • v - Rewrote EventLoop to use Tasks and ContinueWith rather than Actions for performance reasons, and cleaned up the api a little.
    • moved File class to proper namespace.
    • updated File async methods.
    • added File.Read method for streaming file data.
  • v - Added asynchronous http handler for IIS integration.
  • v - Added a static file server implementation.
  • v - Updated web server to use a single event to register all actions
    • removed preprocessor and post processor events.
    • Create method no longer used to register a main event. There is no main event.
  • v - Converted middleware usage to simple event/delegate implementation.
  • v - Abstractions and Middleware capabilities added. Laying the groundwork for a routed server.
    • Abstracted out Server, Request and Response.
    • Added IPreprocessor and IPostprocessor for "before and after" middleware implementations.
    • Added Using method and overloards to IServer to handle attaching middleware.
  • v - Added non-blocking WebSocket implementation
  • v - Fixed a few issues
    • Fixed an issue where EventLoop wouldn't pause when Events Queue was empty.
    • Added Do.Async functionality.
    • Tested multithreaded event-loop processing.
  • v - Updated Sql client Reader call to .NET's non-blocking async call.
  • v - Updated all I/O called to .NET's non-blocking async calls.
  • v - Added a simple SqlClient implementation, ExecuteReader only for now. More soon.


Another Looping Event - An Event Loop Architecture for C#




No releases published
You can’t perform that action at this time.