惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
C
Cybersecurity and Infrastructure Security Agency CISA
G
Google Developers Blog
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
The GitHub Blog
The GitHub Blog
TaoSecurity Blog
TaoSecurity Blog
V
Visual Studio Blog
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
博客园 - Franky
S
Security @ Cisco Blogs
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cyber Attacks, Cyber Crime and Cyber Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
T
Troy Hunt's Blog
B
Blog RSS Feed
A
About on SuperTechFans
IT之家
IT之家
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
J
Java Code Geeks
S
Securelist
T
Threatpost
SecWiki News
SecWiki News
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
aimingoo的专栏
aimingoo的专栏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Forbes - Security
Forbes - Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
D
Docker
N
News and Events Feed by Topic
Schneier on Security
Schneier on Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
月光博客
月光博客
C
CXSECURITY Database RSS Feed - CXSecurity.com
罗磊的独立博客
H
Hacker News: Front Page
N
News and Events Feed by Topic
N
Netflix TechBlog - Medium
AWS News Blog
AWS News Blog
P
Privacy International News Feed
Scott Helme
Scott Helme
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
V
Vulnerabilities – Threatpost
The Register - Security
The Register - Security

博客园 - jiekengxu

工厂方法模式(Factory Method Pattern) 生成器模式(Builder) 抽象工厂模式(Abstract Factory Pattern) asp.net 2.0 权限树的控制(多处转载) 中小型项目的权限管理的数据关系图 简陋的会计凭证金额输入控件(再加强) Web Services Enhancements 3.0 Quick Start(四) 初识HTC asp.net 2.0 缓存(页面输出缓存) asp.net 2.0 缓存(理论篇) 智能客户端概述 Web Services Enhancements 3.0 Quick Start(三) 简陋的会计凭证金额输入控件(加强) Web Services Enhancements 3.0 Quick Start(二) 简陋的会计凭证金额输入控件 Web Services Enhancements 3.0 Quick Start(一) 利用AJAX.net设计现在执行运算的报表 Web Service Software Factory 构架 Web Service Software Factory 入门
单件模式在报表中的使用
jiekengxu · 2006-10-23 · via 博客园 - jiekengxu

       大家可能知道在复杂的并且速度较慢的报表,我们就使用先计算数据,然后再缓存起来,然后在访问报表的时候把直接读缓存就行,所以就可能有"重算" 的功能,来更新这个缓存,所以我们就要限制,在有人重算的时候,保证别人不能重算,在单一的时刻只能一个人在重算,我现在就把我刚学的代码共享出来

using System;

namespace SigletonPattern.Sigleton
{
    
/**//// <summary>
    
/// 功能:在C#用双重锁定实现单件模式
    
/// 编写:jiekeng
    
/// 日期:2006年10月20日
    
/// </summary>

    public class DoubLockSigleton
    
{    

        
private static volatile DoubLockSigleton instance;
        
        
/**//// <summary>
        
/// 辅助锁对象,本身没有意义 
        
/// </summary>

        private static object syncRoot = new Object();

        
/**//// <summary>
        
/// 构造方法改为Private
        
/// </summary>

        private DoubLockSigleton()
        
{
            
        }


        
public static DoubLockSigleton Instance
         
{
            
get 
            
{
                
if (instance == null)
                
{
                    
lock (syncRoot)
                    
{
                        
if (instance == null)
                            instance 
= new DoubLockSigleton();
                        
return instance;
                    }

                }

                
else
                
{
                    
return null;
                }

            }

        }

        
public static void SetInit()
        
{
             instance 
= null;
        }

    }

}

这是核心的代码,我们现在使用客户调用,看看有

  DoubLockSigleton s1 = DoubLockSigleton.Instance;
        
if (s1 != null)
        
{
            Response.Write(s1.ToString());
        }

        
else
        
{
            Response.Write(
"<script language='javascript'>window.alert('已经有人在重算')</script>");
        }

然后是进行类的初始化,不然的话老是"有人在重算"那可不行,好了,一个简单的模型就出来了