Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// V1 Wednesday December 14,2011 8:42 PM
- /// </summary>
- public static partial class WebExtentions {
- public static void LockWrite(this HttpApplicationStateBase application,string key,Func<string,object,object> valueFunc) {
- if(application == null)
- throw new ArgumentNullException("application");
- if(key == null)
- throw new ArgumentNullException("key");
- if(valueFunc == null)
- throw new ArgumentNullException("valueFunc");
- try {
- application.Lock();
- object existing = application[key];
- application[key] = valueFunc(key,existing);
- }
- finally {
- application.UnLock();
- }
- }
- public static void LockWrite(this HttpApplicationStateBase application,string key,object value) {
- if(application == null)
- throw new ArgumentNullException("application");
- if(key == null)
- throw new ArgumentNullException("key");
- try {
- application.Lock();
- application[key] = value;
- }
- finally {
- application.UnLock();
- }
- }
- public static void LockWrite(this HttpSessionStateBase state,string key,Func<string,object,object> valueFunc) {
- if(state == null)
- throw new ArgumentNullException("state");
- if(key == null)
- throw new ArgumentNullException("key");
- if(valueFunc == null)
- throw new ArgumentNullException("valueFunc");
- lock(state) {
- object existing = state[key];
- state[key] = valueFunc(key,existing);
- }
- }
- public static void LockWrite(this HttpSessionStateBase state,string key,object value) {
- if(state == null)
- throw new ArgumentNullException("application");
- if(key == null)
- throw new ArgumentNullException("key");
- lock(state) {
- object existing = state[key];
- state[key] = value;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment