RunUnit.GetInstance Method (Type, Boolean)

MicroFocus.COBOL.RuntimeServices
Given a Type object return the programs instance if the RunUnit knows about it. If create is true then GetInstance will create an instance of programType if it doesn't already have one. Otherwise it will return null should an instance not exist.

Namespace:  MicroFocus.COBOL.RuntimeServices
Assembly:  MicroFocus.COBOL.RuntimeServices (in MicroFocus.COBOL.RuntimeServices.dll) Version: 1.2.3.4
Syntax

[CLSCompliantAttribute(false)]
public IObjectControl GetInstance(
	Type programType,
	bool create
)

Parameters

programType
Type: System.Type
The type of the program to construct.
create
Type: System.Boolean
Whether to create an instance if one doesn't already exist.

Return Value

Type: IObjectControl
An instance of programType or null.

Implements

IRunUnit.GetInstance(Type, Boolean)
Examples

var myRunUnit = new RunUnit();
try
{
 var myProgram1 = myRunUnit.GetInstance(typeof(Program1), true) as Program1;
 myProgram1.Program1("Dobson", 36);
}
finally
{
  // Destroy the run unit
  myRunUnit.StopRun();
}
See Also

Reference