using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Techready14
{
public partial class TR14DataContext
{
private static object createContextLock = new object();
public static TR14DataContext Instance
{
get
{
if (HttpContext.Current != null)
{
var context = HttpContext.Current.Cache["TR14DataContext"] as TR14DataContext;
if (context == null)
{
lock (createContextLock)
{
if (context == null)
{
context = new TR14DataContext();
HttpContext.Current.Cache["TR14DataContext"] = context;
}
}
}
return context;
}
else
return new TR14DataContext();
}
}
}
}
No comments:
Post a Comment