Mercury.QTP.CustomServer Namespace > CustomServerBase Class : InvokeAssistant Method |
class MyRemoteAssistant : CustomAssistantBase { public int Add(int i, int j) { return(i+j); } }
Then create the remote object with CreateRemoteObject and initialize it: MyRemoteAssistant oMyAssistant = (MyRemoteAssistant)CreateRemoteObject(typeof(MyRemoteAssistant));
Set the target control once before first use. oMyAssistant.SetTargetControl(WndHandle.ToInt32());
After the target control is set, the methods of the assistant object can be invoked.
Invocation with InvokeAssistant
causes the method to run in Control's thread. int i = (int)InvokeAssistant(oMyAssistant, "Add", 1, 2);
The method can also be invoked directly if it can run in any thread of the AUT process. int i = oMyAssistant.Add(1,2);
'Declaration
Protected Function InvokeAssistant( _ ByVal Assistant As CustomAssistantBase, _ ByVal Method As System.String, _ ByVal ParamArray args() As System.Object _ ) As System.Object
protected System.object InvokeAssistant( CustomAssistantBase Assistant, System.string Method, params System.object[] args )
Parameters
- Assistant
- The remote Assistant object to be invoked. See CreateRemoteObject
- Method
- The method to invoke.
- args
- A list of Variant parameters.
Return Value