Asynchronous Calls (.NET)
A normal service call blocks the calling thread until the server answers. Usually that's fine, but sometimes you want to fire off a call and let your app keep working — for example to keep a UI responsive while a slow request runs. For that, Remoting SDK lets you call any service method asynchronously.
You don't need to change anything on the server — async calls are handled on the client side and work against any existing server.
The async proxy is generated for you
When you import a service's interface (see How to write a Client), Remoting SDK generates an async version alongside the normal one — for a BusinessLogicService with a Process method you get:
- an async interface
IBusinessLogicService_Async, where every method has an...Asyncversion that returns aTask— e.g.Task<int> ProcessAsync(string value); - a factory
CoBusinessLogicServiceAsyncto create it.
So there's nothing extra to write — just use the Async factory instead of the normal one.
Calling with async / await
Create the async proxy with CoBusinessLogicServiceAsync.Create(...) (same message and channel as a normal proxy), then await the method:
using RemObjects.SDK;
var message = new BinMessage();
var channel = new IpHttpClientChannel();
channel.TargetUrl = "http://localhost:8099/bin";
var service = CoBusinessLogicServiceAsync.Create(message, channel);
int result = await service.ProcessAsync("Hello");
Console.WriteLine($"Server returned: {result}");
That's it — the call runs without blocking, and await gives you the result when it arrives. This is the simplest way to make async calls in modern .NET.
Callback style (Begin / End)
The generated async interface also exposes the classic Begin.../End... pair, in case you prefer a callback or are working with older code. You start the call with BeginProcess and read the result inside the callback with EndProcess:
var service = CoBusinessLogicServiceAsync.Create(message, channel);
service.BeginProcess("Hello", asyncResult =>
{
int result = service.EndProcess(asyncResult);
Console.WriteLine($"Server returned: {result}");
}, null);
Note: with the callback style the result arrives on a background thread, so if you update UI controls from it you must marshal back to the UI thread (e.g. this.Invoke(...) in WinForms). The async/await form above handles this for you automatically.