Use a One-Way Method

Problem

You want a method in a remote object to perform a long task, and you don’t want to force the client to wait while the method code executes.

Solution

Create a one-way method by applying the OneWay attribute from the System.Runtime.Remoting.Messaging namespace.

Discussion

With one-way methods, the client sends a request message, and the remote object responds immediately to indicate it has begun processing. This has several consequences:

  • The client doesn’t need to wait while the method code executes.

  • The method can’t return any information to the client, either through a return value or ByRef parameter.

  • If the method throws an unhandled exception, it won’t be propagated back to the client.

To create a one-way method, you need ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.