zoukankan      html  css  js  c++  java
  • winfrom中使用cache

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web;
    using System.Web.Caching;
    using System.Threading;


    namespace NPao.Tools.EntityDesign
    {
        
    public class CacheConfig
        
    {
            
    private static HttpRuntime _httpRuntime;

            
    public static Cache Cache
            
    {
                
    get
                
    {
                    EnsureHttpRuntime();
                    
    return HttpRuntime.Cache;
                }

            }


            
    private static void EnsureHttpRuntime()
            
    {
                
    if (null == _httpRuntime)
                
    {
                    
    try
                    
    {
                        Monitor.Enter(
    typeof(CacheConfig));
                        
    if (null == _httpRuntime)
                        
    {
                            
    // Create an Http Content to give us access to the cache.
                            _httpRuntime = new HttpRuntime();
                        }

                    }

                    
    finally
                    
    {
                        Monitor.Exit(
    typeof(CacheConfig));
                    }

                }

            }


        }

    }


    使用:
    string s = CacheConfig.Cache["txt"] as string;
                if (!string.IsNullOrEmpty(s))
                    MessageBox.Show(s);
                else
                    CacheConfig.Cache.Insert("txt",txtConnStr.Text);

  • 相关阅读:
    一本通1647迷路
    一本通1646GT 考试
    矩阵
    矩阵快速幂
    数学基础
    清北学堂学习经验(论颓废)
    钟皓曦第二天讲课
    P3275 [SCOI2011]糖果
    P1270 “访问”美术馆
    P2015 二叉苹果树
  • 原文地址:https://www.cnblogs.com/xinzhyu/p/1139413.html
Copyright © 2011-2022 走看看