Rogue Wave Server Component library for .NET Reference Guide
|
|
MvComponentExecDuplexObjectCallbackAsync Method |
This function executes a member callback on the server and get its result in
an asynchronous task.
Namespace: RW.Server.Component
Assembly: RW.Server.Component (in RW.Server.Component.dll) Version: 7.0.0.0 (7.0.0.0)
public Task<MvValue> ExecDuplexObjectCallbackAsync( MvRef mvref, string funNm, MvValue[] args )
Parameters
- mvref
- Type: RW.Server.ComponentMvRef
Reference on the object the callback is member of. - funNm
- Type: SystemString
Name of the callback to execute on server side. - args
- Type: RW.Server.ComponentMvValue
Arguments to send to the server callback.
Return Value
Type: TaskMvValueAn asynchronous result.
The task may be canceled in the two following situations:
- The callback has been rolled back by the server ;
- The component has been disconnected and disposed.
In such a case, an TaskCanceledException is raised.
This exception might be embedded into an AggregateException when
using Result or Wait.
It is possible to wait the result into a separate thread or task.
MvValue[] parameters = new MvValue[2]; parameters[0] = new MvValue(42); parameters[1] = new MvValue(51); var tresult = _component.ExecDuplexObjectCallbackAsync(new MvRef(object),"Multiply", parameters); Task.Run(() => { try { var result = tresult.Result; Console.WriteLine(" Duplex result = " + result.AsString()); } catch(AggregateException e) { Console.WriteLine(" Duplex result canceled."); } });
In an asynchronous function, you can use:
MvValue[] parameters = new MvValue[2]; parameters[0] = new MvValue(42); parameters[1] = new MvValue(51); try { MvValue result = await _component.ExecDuplexObjectCallbackAsync(new MvRef(object),"Multiply", parameters); Console.WriteLine(result.AsString()); } catch(TaskCanceledException e) { Console.WriteLine(" Duplex result canceled."); }