转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 站长学院 >> Web开发 >> 正文
[ADO]如何修改ADO的线程模型         ★★★★

[ADO]如何修改ADO的线程模型

作者:闵涛 文章来源:闵涛的学习笔记 点击数:978 更新时间:2009/4/23 10:50:46
ADO缺省情况下当然是Apartment线程模型。
  If you are using this in IIS and ADO is only being used at page scope 
then it should be fine. 
If you are using it at the session or application level then you will 
need to mark it as both.  

 

那么怎么改为Both呢?

可能就是改一下注册表里面的线程模型。

 

C:\Program Files\Common Files\System\ado

文件夹下,有两个reg文件,很有趣,可能就是这个意思。

ADOFRE15.REG

ADOAPT15.REG

 

其中,ADOFRE15.REG就是这个内容:

REGEDIT4

 

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00000507-0000-0010-8000-00AA006D2EA4}\InprocServer32]
"ThreadingModel"="Both"

 

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00000514-0000-0010-8000-00AA006D2EA4}\InprocServer32]
"ThreadingModel"="Both"

 

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{0000050B-0000-0010-8000-00AA006D2EA4}\InprocServer32]
"ThreadingModel"="Both"

 

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00000535-0000-0010-8000-00AA006D2EA4}\InprocServer32]
"ThreadingModel"="Both"

 

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00000541-0000-0010-8000-00AA006D2EA4}\InprocServer32]
"ThreadingModel"="Both"

 

okay, you''''ll see that the ThreadingModel is adjusted for the following 
coclasses:
 
1. Command
2. Connection
3. Parameter
4. Recordset
5. Error
 
If the threading model selected is "Apartment" (the default), then the
objects listed above can be accessed only by the thread created it.  If
threading model is "Both" and the object is created in an STA, then all
access to it will through the single thread that runs in the STA. If
threading model is "Both" and the object is created in an MTA, then any
thread in this MTA will have direct access to it.
 
If the objects integrate FTM (I don''''t know whether ADO does this or not),
then different threads in different apartments will have direct access to
the objects (without proxies).
或者参见权威的微软文档: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconvisualbasiclanguagechanges.asp

You can configure ADO.NET to use the free-threaded model by importing the following registry data. To modify the registry, copy this data to a REG file (such as Adofre.reg) and import it using the Regedit.exe program (for example, Regedit /s Adofre.reg).

The following registry information is included on Windows 2000 and Windows Server 2003 systems in the Adofre15.reg file. The batch file Makfre15.bat updates the registry with the information in Adofre15.reg. Both files are located in Program Files\Common Files\System\ado\.

REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00000507-0000-0010-8000-00AA006D2EA4}\InprocServer32]
"ThreadingModel"="Both"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00000514-0000-0010-8000-00AA006D2EA4}\InprocServer32]
"ThreadingModel"="Both"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{0000050B-0000-0010-8000-00AA006D2EA4}\InprocServer32]
"ThreadingModel"="Both"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00000535-0000-0010-8000-00AA006D2EA4}\InprocServer32]
"ThreadingModel"="Both"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00000541-0000-0010-8000-00AA006D2EA4}\InprocServer32]
"ThreadingModel"="Both"

If you do not plan to use ADO.NET from ASP.NET applications, you can use the apartment threading model for better ADO.NET performance with legacy applications such as those created with Visual Basic version 6. You can configure apartment threading by importing the following registry data. To modify the registry, copy this data to a REG file (such as Adoapt.reg) and import it using the Regedit.exe program.

The following registry information is included on Windows 2000 and Windows Server 2003 systems in the Adoapt15.reg file. The Makapt15.bat batch file updates the registry with the information in Adoapt15.reg. Both files are located in \Program Files\Common Files\System\ado\.

REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00000507-0000-0010-8000-00AA006D2EA4}\InprocServer32]
"ThreadingModel"="Apartment"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00000514-0000-0010-8000-00AA006D2EA4}\InprocServer32]
"ThreadingModel"="Apartment"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{0000050B-0000-0010-8000-00AA006D2EA4}\InprocServer32]
"ThreadingModel"="Apartment"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00000535-0000-0010-8000-00AA006D2EA4}\InprocServer32]
"ThreadingModel"="Apartment"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00000541-0000-0010-8000-00AA006D2EA4}\InprocServer32]
"ThreadingModel"="Apartment"
 或者参见:

http://www.faqchest.com/msdn/DCOM/dcom-00/dcom-0011/dcom00112713_21236.html

  Date:    Mon, 27 Nov 2000 13:31:04 -0500
From:    Hitesh Mittal <[PRIVACY PROTECTION]>
Subject: Re: Changing threading model of ADO.

go to c:\programfiles\common files\system\ado
you should see adoapt15.reg and  adofre15.reg. Run one of these to register
Apartment or Both.
There is nothing wrong in changing the apartment model to Both, the objects
will be created in the same apartment as the thread is initialized with.
Hitesh Mittal

 

感谢Alex Matevossian和Jim Cirone。

Zhengyun (at) tomosoft.com 收藏。


[Web开发]shopex后台密码忘记了怎么办如何修改  [网络安全]病毒是如何修改软设置破坏计算机硬件的
[办公软件]如何修改幻灯片自定义动画的播放速度  [办公软件]如何修改word公式编辑器里面的文字的字号的大小
[电脑技术]如何修改电脑(计算机)的时间为24小时制、12小时制  [Web开发]Discuz!如何修改Email验证有效性时长
[VB.NET程序]如何修改treeview的背景色  [VB.NET程序]ADO 在informix的 Addnew
[VB.NET程序]ADO 的测试  [VB.NET程序]ADO 揭密 1
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · Web开发  · 网页制作
    · 平面设计  · 网站运营
    · 网站推广  · 搜索优化
    · 建站心得  · 站长故事
    · 互联动态
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台