home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual BASIC 5.0 (Ent. Edition) / Vb5ent Extractor.EXE / VB / SAMPLES / COMPTOOL / ACTVCOMP / COFFEE / ABOUTCOF.TXT next >
Encoding:
Text File  |  1996-12-07  |  5.2 KB  |  103 lines

  1.  
  2. ========>
  3. ========> Coffee Sample Application 
  4. ========>
  5.  
  6. (Coffee2.vbp, CoffWat2.vbp, MTCoffee.vbp, XTimers.vbp)
  7.  
  8. NOTE: Select Word Wrap from the Edit menu for easier viewing.
  9.  
  10. Coffee consists of a client, CoffWat2, and two ActiveX components (OLE servers), Coffee2 and MTCoffee. Together, these three projects demonstrate:
  11.  
  12. ╖ Asynchronous notifications using events (Coffee2).
  13. ╖ Asynchronous notifications using call-back methods (Coffee2).
  14. ╖ Multithreading (MTCoffee).
  15.  
  16. XTimers.vbp is a helper project that provides a code-only timer used by Coffee2 and MTCoffee.
  17.  
  18. This is an expanded version of the project developed in the step-by-step procedures in Chapter 3, "Creating an ActiveX Exe Component," of Creating ActiveX Components. For more information on asynchronous notifications and multithreading, see Chapter 8, "Building Code Components."
  19.  
  20. File            Description
  21.  
  22. CoffWat2.vbp    The CoffeeWatch client project.
  23. CWMod1.bas    Startup code for the project.
  24. CWForm1.frm    The clientÆs main form.
  25. ICoffNot.cls    The ICoffeeNotify interface
  26.         used for call-back methods.
  27. CWNotMe.cls    NotifyMe object implements the
  28.         ICoffeeNotify interface, so it
  29.         can receive call-backs.
  30. CWThread.frm    Client form for demonstrating 
  31.         multithreading.
  32. CWCofTrk.cls    The CoffeeTracker object used 
  33.         to wait for completion events 
  34.         from the multithreaded Coffee 
  35.         object.
  36. Coffee2.vbp    The Coffee2 component project.
  37. Co2Cmon.cls    The CoffeeMonitor class used 
  38.         to demonstrate asynchronous 
  39.         notifications using events.
  40. Co2Conn.cls    The Connector class that lets
  41.         multiple clients share a 
  42.         CoffeeMonitor object.
  43. Co2CMon2.cls    The CoffeeMonitor2 class used 
  44.         to demonstrate asynchronous 
  45.         notifications using call-back 
  46.         methods.
  47. Co2Conn2.cls    The Connector2 class that lets
  48.         multiple clients to share a 
  49.         CoffeeMonitor2 object.
  50. Co2Mod1.bas    Holds a reference to the 
  51.         shared CoffeeMonitor and 
  52.         CoffeeMonitor2 objects.
  53. MTCoffee.vbp    The MTCoffee component 
  54.         project.
  55. MTCoffee.cls    The multithreaded Coffee 
  56.         object.
  57. MTCMod1.bas    A standard module for 
  58.         demonstrating instancing of 
  59.         global data.
  60. XTimers.vbp    The call-back timer project.
  61. XTimer.cls    XTimer object.
  62. XTimerS.bas    Support module for XTimer.
  63. AboutCof.txt    This document.
  64.  
  65. To Run
  66.  
  67. Although there's not a lot of code in it, this is a complex sample to run, because it demonstrates out-of-process components. For debugging, an out-of-process component must be run in a separate copy of Visual Basic.
  68.  
  69. In addition, the sample demonstrates features (multithreading and code-only timers) that either cannot be demonstrated in, or are dangerous to run in, the development environment.
  70.  
  71. 1. Load XTimers.vbp into Visual Basic. On the File menu, select Make XTimers.dll to make the project into a .dll file.
  72.  
  73. IMPORTANT:  DO NOT run XTimers in the development environment at this time. XTimers must be compiled because it uses Windows APIs for a code-only timer object.
  74.  
  75. 2. Load MTCoffee into Visual Basic. On the Project menu, select References to open the References dialog box. Select XTimers and click OK, to set a reference to the compiled DLL.
  76.  
  77. 3. On the File menu, select Make MTCoffee.exe to make the project into an .exe file.
  78.  
  79. IMPORTANT: DO NOT run MTCoffee in the development environment at this time. You need to make the project because the development environment canÆt support multiple threads of execution; if you run MTCoffee within Visual Basic, it wonÆt display multithreading behavior.
  80.  
  81. 4. Load Coffee2.vbp into Visual Basic. On the Project menu, select References to open the References dialog box. Select XTimers and click OK, to set a reference to the compiled DLL.
  82.  
  83. 5. Press CRTL+F5 to run the Coffee2 project.
  84.  
  85. Use CRTL+F5 instead F5 of when running an out-of-process component project, to ensure that all compile errors are caught before the component is supplying objects to the client. (See "Creating an ActiveX Exe Component," in Books Online.)
  86.  
  87. 6. Start another instance of Visual Basic, and load CoffWat2.vbp. On the Project menu, select References to open the References dialog box. Select Coffee2 and MTCoffee, and then click OK, to set references to the running Coffee2 project and the compiled MTCoffee.EXE.
  88.  
  89. 7. Press F5 to run the project.
  90.  
  91. After running the sample application and observing the behavior of MTCoffee when it allocates a separate thread for each Coffee object, you may find it instructive to recompile MTCoffee after changing the threading to a round-robin thread pool. (You can find this option in the Unattended Execution box, on the General tab of the Project Properties dialog box.) When using a round-robin thread pool, you can observe blocking and global data sharing between objects on the same thread.
  92.  
  93. You can also compile Coffee2.exe and CoffWat2.exe, and run multiple clients to observe sharing of the asynchronous notification objects CoffeeMonitor and CoffeeMonitor2.
  94.  
  95. With multiple clients, the round-robin thread pool means blocking and data sharing between Coffee objects in use by different clients.
  96.  
  97. To understand what's going on in this sample, see "Building Code Components," in Creating ActiveX Components in Books Online.
  98.  
  99. To add documents like this to Visual Basic projects, check "Add as Related Document" on the Add File dialog box.
  100.  
  101.  
  102.  
  103.