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

推荐订阅源

量子位
Vercel News
Vercel News
Microsoft Azure Blog
Microsoft Azure Blog
爱范儿
爱范儿
N
Netflix TechBlog - Medium
Google DeepMind News
Google DeepMind News
H
Help Net Security
罗磊的独立博客
The Cloudflare Blog
J
Java Code Geeks
博客园 - 叶小钗
I
InfoQ
B
Blog
Blog — PlanetScale
Blog — PlanetScale
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
腾讯CDC
月光博客
月光博客
博客园_首页
雷峰网
雷峰网
M
MIT News - Artificial intelligence
博客园 - 【当耐特】
美团技术团队
T
The Blog of Author Tim Ferriss
博客园 - 司徒正美

博客园 - 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