Consuming a .NET Delegate

In PowerBuilder .NET, you can invoke .NET delegates from PowerScript code. Delegates allow you to treat functions as entities that can be assigned to variables and passed as parameters.

A delegate type represents references to methods that have a particular parameter list and return datatype.

The PowerBuilder .NET IDE exposes all the visible delegates in the .NET assemblies referenced by the current target in the Solution Explorer or object browser.

  1. Import an assembly containing a .NET delegate to a PowerBuilder .NET target.
  2. Determine whether to invoke the .NET delegate synchronously or asynchronously.
  3. Write PowerScript code to assign a function or functions to a variable that has the .NET delegate type.
Next

If you invoke the delegate asynchronously, determine whether to join the results immediately after the invoked thread completes its execution, after a callback function is triggered, or as the result of polling that allows other processing to complete even after the child thread has finished running.

You can also decide whether to use multicasting, which uses a function chain that passes arguments by value or reference from one function to another in a single invocation of the .NET delegate.