How to Make Any Operation Asynchronous in .NET

I’m in the middle of writing some updates to Quick and Dirty Feed Parser for use in a new personal project of mine; namely, I need to make QD Feed Parser work asynchronously so I can use it in conjunction with asynchronous controllers in ASP.NET MVC3, and eventually Silverlight + Windows Phone 7.

Asynchronous network IO is a breeze in every version of .NET since 1.1 – WebRequest and many others have supported asynchronous methods for as long as I’ve been using them. However, asynchronous disk IO, which I need to support in QD Feed Parser, is not something that comes so easily in .NET 4.0 and below.

StreamReader is the most user-friendly tool for reading files off of local disk because you don’t have to manage any buffers or do any of the sort of accounting that a class like FileStream requires[footnote:It should be noted that...

Read More

Upgraded to BlogEngine.NET 2.0, Updated Extensions

BlogEngine.NET 2.0 was released just before Thanksgiving this year, and it includes a bunch of major changes, the most noticeable of which is the drastically improved admin dashboard.

There are also a number of external-facing improvements too such as jQuery out of the box, SEO improvements, and so forth. I contributed one small improvement to BlogEngine.NET 2.0, and that was the alternative captcha engine I wrote – Recaptcha causes as many problems as it solves and was rife with bugs in BlogEngine.NET 1.6 [footnote: just ask the people who were trying to comment on my post on ASP.NET MVC3 Remote Validation the other day].

SimpleCaptcha

SimpleCaptcha was inspired by the captcha engine Jeff Atwood used on Coding Horror for so many years, where he asked his bots to politely type in the word “orange.” In that vein I decided to follow in his footsteps.

The default SimpleCaptcha out...

Read More

Quick and Dirty Feed Parser 0.3 Now Available

My Christmas gift to the developer community: Quick and Dirty Feed Parser 0.3 is now available on CodePlex!

The big feature added in this release is the ability to perform IFeedFactory.CreateFeed operations asynchronously both for disc IO and network IO. I added this to QD Feed Parser primarily to support the use of asynchronous controllers in ASP.NET MVC3, and to support Silverlight and Windows Phone 7 eventually.

All classes which implement the IFeedFactory interface now have some new members:

IAsyncResult BeginCreateFeed(Uri feeduri, AsyncCallback callback);

IFeed EndCreateFeed(IAsyncResult asyncResult);

IAsyncResult BeginDownloadXml(Uri feeduri, AsyncCallback callback);

FeedTuple EndDownloadXml(IAsyncResult asyncResult);

If you’re at all familiar with the Begin[Procedure] End[Procedure] asynchronous programming pattern in .NET, then the purpose of these functions should be self-evident. Internally, BeginCreateFeed and EndCreateFeed are dependent upon the output...

Read More

Fluent NHibernate: How to Create Bidirectional Many-to-Many Relationships with Additional Attributes on Relationship Table

Suppose you have a relationship that looks like this in your database:

fluent-nhibernate-complex-many-to-many-mapping

This is a common use-case. In this instance, I wanted to be able to create a table which would log all of the times an individual user read a particular item from an RSS feed. I used an identity key here instead of a composite key so I could take advantage of NHibernate’s auto-magical SaveOrUpdate feature.

Normally with a ManyToMany relationship between two entities in Fluent NHibernate you would simply define a HasManyToMany attribute on either side of the entity, and .Inverse one of them such that only one entity is actually responsible for persisting changes to the database.

In this type of relationship, where your many-to-many relationship actually has additional...

Read More

Los Angeles Azure 101 Event - 12/16/2010

Just a quick post for any readers in the Southern California area who are interested in learning more about Windows Azure. My team is putting on an event at Microsoft's Los Angeles offices on Thursday morning from 9:00am to 1:00pm and its intent is to help introduce Azure to any curious developers who've never had a chance to play around with it before. These guys are all top-notch Azure experts and will be able to answer your questions better than I ever could :p

Register or learn more:

http://bit.ly/laazure 

Read More

How-To: Remote Validation in ASP.NET MVC3

ASP.NET MVC3 has been a major boon to my productivity as a web developer since I started using it at the beginning of November – the new Razor view engine has been attracting most of the attention with this iteration of MVC, but one extremely sexy feature has gone unnoticed thus far: Remote validation.

Remote validation was one of the new features added in the November Release Candidate (RC) for MVC3 – I had a chance to demo it in front of the LA .NET User Group last night and it was a monster hit.

Example:

You’ve all seen remote validation before – ever see one of these when you’re signing up for a service like Twitter?

image

That’s remote validation at work. Twitter, Facebook et al make...

Read More

Where Are My Windows Phone 7 Icons?

appbar.favs.addto.rest This is a quick post, but for anybody who isn’t using Expression Blend (which automatically puts all of the Windows Phone 7 icons for you in a drop-down list as default resource values for images) and wants to get access to icons in Windows Phone 7, here is where you can find them:

C:/Program Files (x86)/Microsoft SDKs/Windows Phone/v7.0/Icons/

image

Read More

LA .NET User Group ASP.NET MVC3 Lecture Notes

Putting this online for the benefit of the .NET LA User Group – this content is meant to accompany my talk on ASP.NET MVC3:

ASP.NET MVC3 links:

Source code:

PeerLearningSite on Github (Example Project with ASP.NET MVC3 RC)

Presenters:

Lastly, join...

Read More

How to Make it Easy for New Developers to Adopt Your Open Source Project

James Gregory is one of my heroes in the .NET community – he’s the creator of Fluent NHibernate, my favorite new ORM (Object-Relational Mapper) for my ASP.NET MVC projects. James expressed some dismay earlier today when a newbie Fluent NHibernate developer posted a $100+ bounty for a few basic usage examples; having just recently taught myself the very things the developer was asking for, I can empathize.

NHibernate (Fluent NHibernate runs on top of it) is a bear of an open source project for new developers – it’s a mature project that solves a problem with a massive surface area and the NHibernate community is comprised of experienced developers who’ve been using it for years. It can be difficult for new developers to get involved, as the learning curve is steep even for just adopting the project, let alone contributing to it.

So how can we...

Read More

Consuming REST in .NET

I gave a talk at Code Camp Los Angeles a couple of weekends ago on how to consume REST APIs in .NET – the emphasis was really on understanding RESTful principles and on the OAuth workflows + implementing them in Windows Phone 7.

It was meant to be a 100-200 level introduction to the REST in .NET – if you’ve implemented OAuth before in .NET then this is old news for you :p

Enjoy!

Read More

P.S. Get the latest from Aaronontheweb

Have my most recent essays and articles delivered directly to your mailbox.