Use a Sponsor to Keep Remote Objects Alive

Problem

You want to keep a remote object alive while it’s in use, but you don’t want to be forced to periodically call the ILease.Renew method from your client.

Solution

Create and register a lease sponsor that will automatically renew the remote object.

Discussion

.NET Remoting introduces the ideas of lifetime leases and lease sponsors. A lease sponsor is remotable object that runs in the client’s application domain. It has a single purpose—to keep the remote objects your application is using alive.

The lease sponsor doesn’t interact with the remote object directly. Instead, it waits for the .NET Remoting infrastructure to initiate communication. Whenever a remote object is about to expire, .NET will contact ...

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.