MS COM and subsequent DCOM / COM technology supported by distributed objects are still widely used, but the official statement should be .NET, .NET, how much I don't know, DCOM has more than a slightly One two, especially the implementation of Visual Basic.
The predecessor of COM is OLE, mainly used to solve collaboration between office multi-documents, OLE itself and complex, some of which are the reason for the complexity of essentials. In general, you can accept it.
However, in order to increase location transparency and use in the development of background components, MS uses the DCE RPC protocol to extend COM. The prototype of the DCOM itself is very simple, an RPC mechanism, but due to the essential technical characteristics of some MS products, it is distorted its implementation, some specifically referred to Visual Basic and MFC.
Visual Basic, including MFCs with threads, what is threading? For example: I have a Class A, a method foo (),
Class a {void foo () {...}};
If there is n thread T1 .... TN, I call a a = new a in the T1 thread; then run a-> foo () this is not any problem.
But because we are multithreaded programs, suppose now the T2 thread is coming, I give this T2 thread with a pointer, then in the T2 thread, I want to call A-> foo () should have no problem, even if Class A The foo itself does not provide a thread protection mechanism, as long as other threads T1, T3 ... TN should be able to call the FOO at this time. right?
Unfortunately, in the DCOM model, because the Visual Basic has threaded relatives, A. This object is created in the T1 thread, then the object is bound to the T1 thread, all method calls must only be in the T1 thread. run. (This is why the T1 thread requires a message loop because the T2 thread is called when the FOO method is called, and then calls T1 SendThreadMessage, and then transforms through the thread, running in the thread environment of T1, then switch to T2 thread again. , Get the result of the call).
What will this lead to something? Hit a bit, assuming that you have a new bank account in a certain bank (corresponding to new Component), there are 10 windows in the bank counter (10 threads corresponding to your service), next time you are ready to access At the time (corresponding to this Component), it is found that the bank has such a notice: The bank system has passed Apartment International Certification (Apartment thread model that should be used to use DCOM), please customer work The specific window to open an account is waiting in line. Thanks for your cooperation!
You found all the waitingers (corresponding to some DCOM objects) this day (corresponding to some DCOM objects) is open at the 1st window (corresponding in the T1 thread), you are like this, the result, you are row The long dragon behind the first window, waiting for your time film. There is almost no other 9 windows. Your eyes are looking at the non-No. 1 window of the non-No. 1 window. It is easy to finish their business. When you leave, you will have a few eyes in a puzzled eye. Do you feel that you like a SB, unlimited depressed, the fire is likely to want @ # @ ## @ ¥, right?
Of course, the bank also provides several solutions, look forward to it? You have discovered several solutions from the bank's Bank Guide magazine, one is to implement the bank's internal implementation. It purchased a piece of land next to it, expanding the number of bank counters to 100 (corresponding to the first MTS 100 threads), It is expected that you can shorten your wait time through random principles. But you find that the bank will start the handling fee, so this place, the staff behind these windows can not be free (corresponding to the resource consumption caused by thread switching, scheduling).
Another way to introduce the Band Guide magazine is more effective, and it is clear that you die. It is to suggest that you go to the bank every time, you are re-opening, then apply business (Invoke), finally log out of the account (delete), correspond to the "death" that I said, "You should know that VB written COMPMENT can't be used DCOM Pool, right?). The bank's explanation is: This can alleviate the burden on our account database (used in memory). You now feel that it is not only you, but also this bank, it belongs to the mentistency of the BT level, right? This is the world of the Apartment thread model of DCOM.
So how many such banks do? I estimate that about 80% may be. Because it is said that VB's developers exceed 10 times that of VC, you can imagine how many business layer components are developed using VB. As mentioned earlier, because the runtime of Visual Basic has a threaded property, all VB development of Component is the case, so it can generally estimate how many components are passed by Apartment International.
What a great solution!