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

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
The GitHub Blog
The GitHub Blog
C
Check Point Blog
博客园_首页
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
F
Full Disclosure
Microsoft Security Blog
Microsoft Security Blog
爱范儿
爱范儿
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
G
GRAHAM CLULEY
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Threat Research - Cisco Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
K
Kaspersky official blog
博客园 - 司徒正美
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
Project Zero
Project Zero
云风的 BLOG
云风的 BLOG
Cisco Talos Blog
Cisco Talos Blog
Know Your Adversary
Know Your Adversary
雷峰网
雷峰网
V
V2EX - 技术
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Spread Privacy
Spread Privacy
罗磊的独立博客
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
SecWiki News
SecWiki News
Schneier on Security
Schneier on Security
O
OpenAI News
Jina AI
Jina AI
PCI Perspectives
PCI Perspectives
Cyberwarzone
Cyberwarzone
Y
Y Combinator Blog
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog RSS Feed
I
InfoQ
D
Docker
P
Palo Alto Networks Blog
Recorded Future
Recorded Future
M
MIT News - Artificial intelligence
博客园 - Franky
B
Blog
Scott Helme
Scott Helme
博客园 - 叶小钗
D
DataBreaches.Net

博客园 - 漫步人生

c# 使用GetOleDbSchemaTable获取access数据库结构 xp上vs2010+IE8无法调试脚本 iis 上部署asp.net程序出错排查 windows2008的共享 使用sqlite绿色部署问题 在vs中使用正则表达式 - 漫步人生 事件不应该有返回值 ae的com对象在dotnet中的释放问题 修改Windows中ASPNET账户的密码 ae显示arcserver的地图服务 arcgis 编辑时独占mdb - 漫步人生 adf for dotnet中动态给ArcGis Server服务添加图层 js中在不知道属性名时获取属性对象 html文档中的name属性 ie中js a光标位置 - 漫步人生 adf中UpdatePanel刷新地图 - 漫步人生 windows局域网内以arcgis server local的方式连接arcserver服务器 - 漫步人生 c#与 如何调试 - 漫步人生 C#与C/C++的互操作 - 漫步人生
adf for dotnet中servercontext的释放
漫步人生 · 2011-10-28 · via 博客园 - 漫步人生

当使用local数据源做adf开发的时候,就可能接触到serverconttext,获取方法是MapResouceLocal.ServerContextInfo.ServerContext。

IServerContext对应的就是ArcServer上的用来处理请求的一个soc.exe进程。在esri的帮助文档中有这样一段话

When your application is finished working with a server context, it must release it back to the server by calling the ReleaseContext method. If you allow the context to go out of scope without explicitly releasing it, it will remain in use and unavailable to other applications until it is garbage collected. Once a context is released, the application can no longer make use of any objects in that context. This includes both objects that you may have obtained from the context or objects that you created in the context.

对于ArcServer的NoPooled的情况应该是在不再使用(如用户退出登录)的时候释放IServerCotnext。

下面主要讨论Pooled的情况,现在怕也没人用NoPooled这种方式了。

一、所以需要每次处理http请求的最后释放掉ServerContext,但在开发的时候(比如写一个tool)发现,当http在处理请求的时候,确实占用了一个ServerContext(使用arcserver提供的webmanager可以看到当前正在使用的Instance及servercontext数量),但我们并没有在代码中释放ServerContext,可处理完请求后,发现ServerContext还是释放掉了。那肯定是adf框架自己帮我们释放掉了,查看源代码发现GISResourceManager<T, R>.Dispose方法,该方法又调用了DataSourceManager.Dispose方法,在该方法中调用了IGISResourceIGISFunctionality的Dispose方法,对于local连接,MapResourceLocal.Dispose方法中释放了ServerContext。

二、如果自己连接ArcServer,通过IServerObjectManager.CreateServerContext创建的ServerContext需要自己写代码释放,最好是用完就释放。

三、如果页面写了一个ajax请求,而这个ajax请求就是一般的asp.net ajax请求(没有用adf提供的ajax方法请求,及没有通过Map控件来处理请求),如果在处理这个ajax请求时用到了ArcServer的远程对象,这个时候必须要自己写代码来释放ServerContext。为什么会出现这种情况呢,原来GISResourceManager<T, R>.Dispose方法会判断它自己是否initialed,如果没有则不会执行释放操作:

if (this.m_initialized || base.m_atLeastOneResourceInitialized) {

this.OnResourcesDispose(null);

base.DataSourceManager.Dispose();

this.m_initialized = false;

base.m_atLeastOneResourceInitialized = false; }

而无论是加载整个页面还是,通过Map控件来处理ajax请求,查看GISResourceManager.Initialized属性均为True,而自己实现一个asp.net ajax请求时,该属性为False。