Article ID: 191967 - Last Review: August 6, 1999 - Revision: 1.0

PRB: Visual FoxPro In-Process Servers Do Not Run Concurrently

System TipThis article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
This article was previously published under Q191967

On This Page

Expand all | Collapse all

SYMPTOMS

When a Visual FoxPro 6.0 Component Object Model (COM) component (DLL) is accessed by multiple threads (or processes, if the Visual FoxPro component is part of a Microsoft Transaction Server package), if one thread calls a method on the component while another thread is already executing a method, the new method call will not begin executing until the existing method call has finished.

CAUSE

In the object implementation in Visual FoxPro, entry into the run-time is blocked while another object is in execution.

STATUS

This behavior is by design.

MORE INFORMATION

In order to preserve data integrity of variables, Microsoft Visual FoxPro blocks entry into the run-time while another object is in execution.

Steps to Reproduce Behavior

  1. Create a Visual FoxPro COM .dll, called VFPMTS, by adding a program file with the following code to a project:
          DEFINE CLASS MTSServer as Custom OLEPUBLIC
    
          oAPPServer = .NULL.
          oObjectContext = .NULL.
          cErrorMsg = ""
    
          FUNCTION FastHit
             RETURN "Done. " + TIME()
          ENDFUNC
          FUNCTION SlowHit
          LPARAMETER lnSecs
             lnSecs=IIF(type("lnSecs")="N",lnSecs,5)
    
             THIS.oAppServer = CREATEOBJECT("MTXaS.Appserver.1")
             THIS.oObjectContext = THIS.oAppServer.GetObjectContext()
    
             lcOutput = ""
    
             FOR x = 1 to lnSecs * 300000
                i=1
             ENDFOR
    
             THIS.oObjectContext.SetComplete()
             RETURN lcOutput + "Done waiting for "+STR(lnSecs)+" secs"
          ENDFUNC
          FUNCTION Error
          LPARAMETER lnErrorNo, lcCode, lnLine
    
             THIS.cErrorMsg = THIS.cErrorMsg + STR(lnErrorNo)+ " - " ;
             + STR(lnLine) + " " + lcCode + " - " +Message()
          ENDFUNC
          ENDDEFINE
    						
  2. Build the project into a multi-use COM .dll then add it to Microsoft Transaction Server (MTS) using the Import Component option of an MTS package.
  3. Start up two Visual FoxPro sessions.
In Session one, run the following code from the Command window:
   o=create("vfpmts.mtsserver")
   ? o.SlowHit(35)
				
In Session two run the following code from the Command window:
   o=create("vfpmts.mtsserver")
   ? o.FastHit()
				
Make sure you run the call to FastHit after SlowHit starts.

Notice that the FastHit does not start until after the SlowHit completes.

APPLIES TO
  • Microsoft Visual FoxPro 6.0 Professional Edition
Keywords: 
kbcode kbprb KB191967
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.