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

推荐订阅源

The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
B
Blog RSS Feed
大猫的无限游戏
大猫的无限游戏
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
Hugging Face - Blog
Hugging Face - Blog
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
B
Blog
小众软件
小众软件
T
Tailwind CSS Blog
MyScale Blog
MyScale Blog
I
InfoQ
Engineering at Meta
Engineering at Meta
Blog — PlanetScale
Blog — PlanetScale
P
Proofpoint News Feed
H
Help Net Security
雷峰网
雷峰网
S
SegmentFault 最新的问题
V
Visual Studio Blog
爱范儿
爱范儿

博客园 - shcity

Troubleshooting on TransactionScope Parse string to JSON object Parse date in js blockUI doesn't close when download file in asp.net define namespace in JS Dense_Rank(), Row_Number(), Rank() in sql server Fix the issue that cannot open SSIS in BIDS three ways creating custom helpers to show RadioButtonList in MVC using JavaScriptSerializer to serialize object to json using ISerializable to control serialization and deserialization ViewStateAutoManager ReportingService formatting Build my own DataTable split a string into an array through comma div with separated html template - shcity 正则表达式替换日期 半透明的div对话框 foreach 的自动转化类型 在Ajax1.0中调用页面CS文件中的方法
reading and writing variable through lock in SSIS script ...
shcity · 2013-03-03 · via 博客园 - shcity

why we need lock to read or write variables, if we don't use lock, sometimes a deadlock will occur.

writing variable:

private void WriteValue(string name,object value)
        {
            Variables variables = Dts.Variables;

            try
            {
                Dts.VariableDispenser.LockOneForWrite(name, ref variables);
                variables[name].Value = value;
            }
            finally
            {
                if (variables.Locked)
                {
                    variables.Unlock();
                }
            }

        }

reading variable:

private object ReadValue(string name)
        {
            Variables variables = Dts.Variables;

            try
            {
                Dts.VariableDispenser.LockOneForRead(name, ref variables);
                return variables[name].Value;
            }
            finally
            {
                if (variables.Locked)
                {
                    variables.Unlock();
                }
            }
        }

 more information:

http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.variabledispenser.lockforwrite.aspx