IIS是一个线程服务器,每一个asp都是一个线程,因而跨session,application就必须满足这一点。遗憾的是,vb是一个面向高级应用的开发工具,并不支持跨线程的组件,只能编写单线程的组件。而猴版的vbs更是如此,在vbs中用class定义出来的对象一样不允许跨线程。
要突破这一点,就必须使用vc,cb之类低级的开发工具,而其中手工定义接口,IDispatch,IUnknown,UID之类的事,让人头昏脑涨,即便是vs.net 2005 , cb6中 ,也似乎没有多少改善。
下面引用cb的一段帮助来说明各种组件的不同
Automation Objects can have one of the following:
Single Only one client thread can be serviced at a time. COM serializes all incoming calls to enforce this. Your code needs no thread support.
Apartment Each object instantiated by a client is accessed by one thread at a time. You must protect against multiple threads accessing global memory, but objects can safely access their own instance data (object properties and members).
Free Each object instance may be called by multiple threads simultaneously. You must protect instance data as well as global memory.
Both This is the same as the Free-threaded model, except that all callbacks supplied by clients are guaranteed to execute in the same thread. This means you do not need protect values supplied as parameters to callback functions.
Neutral Multiple clients can call the object on different threads at the same time, but COM ensures that no two calls conflict. You must guard against thread conflicts involving global data and any instance data that is accessed by more than one method. This model should not be used with objects that have a user interface. This model is only available under COM+. Under COM, it is mapped to the Apartment model.
希也不要太深究此问题,C程序员和asp程序员的薪水差别之大是显而易见的,我想当真能够用c编写出需要的组件时,没人舍得回到廉价的asp工程上了。