Lecture #12 - COM Apartment Model

Isolation

Web Resources:

Linux Tutorials eclipse Code Project SysInternals Best SysInternals Tools Dr. Dobb's Journal Windows Forms COM at MSDN IDL Language base MIDL types OLE data types IDL attributes MIDL data types MIDL Language Reference

Content:

In this lecture we discuss COM Apartments.

  1. Syllabus describes topics to be covered, reading material for you to digest before coming to class, and due dates for the assigned projects.
  2. Projects:

    Project #1, Project1HelpS16
    Final Projects, Project Presentations Schedule xlsx

    Tasks and ThreadPool, C++ Sockets, C++ File Manager, FileSystem-Windows, FileSystem-Linux
    C++ BlockingQueue, C++ Concurrency
    C++ DLL Demo

  3. Thread Locking Performance

    Testing C++11 synchronization performance
    How does C++11 synchronization performance compare to Win32 synchronization?
  4. Technology Presentations
  5. Building COM Projects

  6. Connection Points:

    Connectable Objects
    Introduction to Connection Points.

    ATLProject1_Helper
    Demonstrates building a simple component with connection point callbacks and both C++ and C# clients.

    Late Binding, ppt

    Late Binding COM Events, ppt
  7. Out-of-Process COM Components

    OutProc Presentation

    OutProc Class Diagram, OutProc Sequence Diagram
    OutProc ST Structure Chart, OutProc MT Structure Chart

    IDL Demo - Interfac
    We looked at this before. It's here as a reminder that all the interface method parameters were being marshalled between the client and component processes.

    Raw C++ Out-of-Process Single-Threaded Apartment Component
    We will go through this code carefully so you see the structure of an out-of-proc COM component.

    Raw C++ Out-of-Process Multi-Threaded Apartment Component
    We will make a quick comparison of this with the previous code so you see the differences between ST and MT code.

    ATL Out-of-Process Single-Threaded Apartment Component
    This is the ATL-based version of the OutProcST project.

    OutProc with console
    Out-of-Process components have no visible interface unless you add one. This demonstrates how to add a console.

    OutProc with dialog
    Out-of-Process components have no visible interface unless you add one. This demonstrates how to add a dialog.

  8. COM Apartments

    COM Apartments Presentation

    Thread Rules

    Understanding COM Apartments, Part I - Jeff Prosise, Understanding COM Apartments, Part II - Jeff Prosise Eight Lessons from the COM school of Hard Knocks

    Marshaling Interface Pointers between Client Threads
    You can't pass interface pointers between apartments witout marshaling. To do so breaks the COM threading model. This project shows you how to do that marshaling.

    Component calls component
    This project demonstrates how to marshal an interface pointer through a COM interface. Look at the IDL for the OutterComp. You will see it pass an interface pointer to the InnerComp back to the client. The inner component is created by the outter component, but at the end the client needs to access the inner component to get its state information, so the client just uses the returned (marshaled) interface pointer for that.

  9. Distributed COM: and COM+

  10. Other COM Topics:

    Windows Template Library (WTL)
    Thin windows library created by ATL team.

    Structured Storage
    Demonstration of Structured Storage, e.g., file system in a file.

    Speech API
    Quick demo of Speech API - built with COM.

    Accessing Registry
    Programming the Registry (no guarantee it's bug free - buyer beware)

    Monikers
    Monikers are COM links between other COM objects and files, etc.

    Marshaling COM Pointers in Stream
    Demonstrates marshaling a COM pointer between Apartments using streams.

    COM Persistance
    Quick demo of COM persistance.

    Automation with IDispatch
    Demonstates use of Automation with a raw C++ IDispatch implementation.

    Demo ActiveX Control
    Demonstrates a simple composite ActiveX Control running in a web page.
  11. JavaScript and Go

  12. RESTful Web Services

CST strip