Go back

Neil Bostrom: Microsoft TechEd (Wednesday)

Building Highly Scalable ASP.NET Web Sites by Exploiting Asynchronous Programming Models

Stefan Schackow gave a good in-depth talk on how IIS and ASP.NET handles request and how this affects the available threads in the thread pool. To do any async work in asp.net pages you always need to add Async="true" to the page header. He first described using AddOnPreRenderCompleteAsync to run asynchronous tasks (database calls, web service calls, IO). Turns out this method is a backwards compatible method as its a bit useless since it does not allow you to run multiple tasks and you're also limited to getting your data after the prerender which is a little late to do anything with. A small catch me out is that in the end method of the async event no HttpContext is available. A better way to handle async tasks is to use the PageAsyncTask class. This class allows you to run multiple tasks and control when it runs and it still frees up the thread during the call. You would create a task and register it with the page using RegisterAsyncTask() method. To force the task to run earlier than the prerender, use the ExecuteRegisteredAsyncTasks() method.

Writing Maintainable and Robust Applications with Visual Studio 2008 Team Edition for Software Developers

This session gave a great impression on what tools are available to make sure that your applications are more likely to be bug free. One of the best tools show was the code coverage, which is now integrated with the unit testing framework within Visual Studio. Code analysis is something I believe we need to start using at Compsoft. They showed some good examples where the rules the code analysis runs raises some major issues which you wouldn't normally spot in your code. The unit testing tools shipped with Visual Studio 2008 have been improved with inline "Run Test" options. Code complexity is another tool that is shipped with VS 2008.

Entity Framework: Application Patterns

Pablo Castro brought a fantastic session on practical uses of the ADO.NET entity framework. Pablo went through a bunch of application architectures and how to use entity framework in each one. First he covered the simple 2 tier application like a console app wired up to a database. He then moved on to 3 tiers, giving web application as a sample. Finally finishing up with n-tier application using web service. One of the handy tip I gain during these samples is that you can turn off tracking of object on your context if you believe you're not going to be doing any updates. This massive improves performance as the context doesn’t need to track any objects. Another tip suggested is that you should never really cache your context, always create a fresh ObjectContext when making changes or working with the database. You can run into massive concurrency issues if you reuse context objects. All objects generated by the entity diagram implement ISerializable, this allows any object to be stored in the viewstate to be passed around your pages. When using the context object, always try to make sure you wrap it in a using statement. This makes the code “dispose” friendly in case any of the databases you're working with in your entities are not that connection friendly. Interesting topic was raised about setting foreign keys. Currently in our own framework we expose an Id property to allow direct use of the internal id when working with the objects. This helps in web applications when you most likely only have the id and don’t want to retrieve the full object to just persist the id. The nice thing is this has been covered in LINQ to Entities. (LinkName)Reference.EntityKey has the mapping to the integer of the foreign key. This allows you to retrieve and set the foreign key on an object without retrieving the full object. Pablo also covered the ability to cache LINQ statements for performance.

Got a project? Let's work together

Compsoft is a remote working company except for Thursdays when we work together from the Alton Maltings in Alton, Hampshire (UK). Our registered address is detailed below. We'd be delighted to have either a virtual chat with you or to make arrangements to meet in person.