• Explain single thread and multithread thread apartments.
All components created with Visual Basic use the apartment model, whether they’re single-threaded or multithreaded. A single-threaded component has only one apartment, which contains all the objects the component provides.
This means that a single-threaded DLL created with Visual Basic is safe to use with a multithreaded client. However, there’s a performance trade-off for this safety. Calls from all client threads except one are marshaled, just as if they were out-of-process calls.
• What is a Component?
If you compile an ActiveX dll, it becomes a component.If you compile an ActiveX Control, it becomes both a component and a control.
Component is a general term used to describe code that's grouped by functionality. More specifically, a component in COM terms is a compiled collection of properties/methods and events.
Typically a component is loaded into your project via the References whereas an ActiveX Control is loaded into your project via "components".
• What is meant by "Early Binding" and "Late Binding"? Which is better?
Early binding and late binding refer to the method used to bind an interface's properties and methods to an object reference (variable). Early binding uses type library information at design time to reference procedures, while late binding handles this at run time. Late bindinghandles this by interrogating the reference before each call to insure that it supports a particular method. Since every call to a late boundobject actually requires two calls ("Do you do this?" followed by "Okay, do it then"), late binding is much less efficient than early binding. Except where early binding is not supported (ASP, scripting, etc.), late binding should only be used in very special cases.
It is a common misconception that any code using the CreateObject function instead of
Set = New is using late binding. This is not the case. The type declaration of the object variable determines whetherit is late or early bound, as in the following:
Dim A As Foo
Dim B As Foo
Dim C As Object
Dim D As Object
Set A = New Foo 'Early Bound
Set B = CreateObject("FooLib.Foo") 'Early Bound
Set C = CreateObject("FooLib.Foo") 'Late Bound
Set D = New Foo 'Late Bound
All components created with Visual Basic use the apartment model, whether they’re single-threaded or multithreaded. A single-threaded component has only one apartment, which contains all the objects the component provides.
This means that a single-threaded DLL created with Visual Basic is safe to use with a multithreaded client. However, there’s a performance trade-off for this safety. Calls from all client threads except one are marshaled, just as if they were out-of-process calls.
• What is a Component?
If you compile an ActiveX dll, it becomes a component.If you compile an ActiveX Control, it becomes both a component and a control.
Component is a general term used to describe code that's grouped by functionality. More specifically, a component in COM terms is a compiled collection of properties/methods and events.
Typically a component is loaded into your project via the References whereas an ActiveX Control is loaded into your project via "components".
• What is meant by "Early Binding" and "Late Binding"? Which is better?
Early binding and late binding refer to the method used to bind an interface's properties and methods to an object reference (variable). Early binding uses type library information at design time to reference procedures, while late binding handles this at run time. Late bindinghandles this by interrogating the reference before each call to insure that it supports a particular method. Since every call to a late boundobject actually requires two calls ("Do you do this?" followed by "Okay, do it then"), late binding is much less efficient than early binding. Except where early binding is not supported (ASP, scripting, etc.), late binding should only be used in very special cases.
It is a common misconception that any code using the CreateObject function instead of
Set = New is using late binding. This is not the case. The type declaration of the object variable determines whetherit is late or early bound, as in the following:
Dim A As Foo
Dim B As Foo
Dim C As Object
Dim D As Object
Set A = New Foo 'Early Bound
Set B = CreateObject("FooLib.Foo") 'Early Bound
Set C = CreateObject("FooLib.Foo") 'Late Bound
Set D = New Foo 'Late Bound
0 comments: