Skip to content

DevConnections Presentation Orlando, How To Make Your Browser fly

Updated: at 02:12 PM

(About 100 People)

The Presentation was broken down into three parts. 

Part 1

Created a windows razor project that cached in image on a web site using best practices for threading and locking.  The code and project to do this are below:

var downloadByteArray = HttpContext.Current.Cache[cacheName] as byte[];
if (downloadByteArray == null)
{
// make sure multiple requestors are not filling up the cache
lock (LockVal)
{
downloadByteArray = HttpContext.Current.Cache[cacheName] as byte[];
if (downloadByteArray == null)
{
Thread.Sleep(sleep * 1000);

string imageLocation = HttpContext.Current.Server.MapPath("~") + imageUrl;

downloadByteArray = File.ReadAllBytes(imageLocation);
if (cacheExpiresSeconds > 0)
{
HttpContext.Current.Cache.Insert(cacheName, downloadByteArray,
null,
DateTime.Now.Add(new TimeSpan(0, 0, 0, cacheExpiresSeconds)),
TimeSpan.Zero, CacheItemPriority.NotRemovable, null);
CacheInsertCounter = 9999; // any touch of this increments the global counter
}
}
}
}

 

 

Part 2

Tips from Steve Souders

 

Part 3

Sprite Library from Microsoft Example: 

 

imageIMAG0174IMAG0177

Check out the ORM (Object Relational Mapper) PRISMA. The database access method I use in all my projects