Step by step Remoting two: Activation mode

Source: Internet
Author: User
Tags constructor
The activation mode of the remote object is server-activated and client-activated, (that is, Object-server-activated objects or well-known objects and client-activated objects two) First look at how MSDN describes server-side activation:
Server-activated objects are objects whose lifetimes are directly controlled by the server. The server application domain creates these objects only when the client makes a method call on the object, and does not create them when the client calls new or Activator.GetObject; This saves a network round trip to create the instance only. When a client requests a server-activated instance of a type, only one agent is created in the client application domain. However, this also means that when you use the default implementation, only the default constructor is allowed for types that are activated by the server. To publish a type that its instance will create with a specific constructor with parameters, you can use client-side activation or dynamically publish your specific instance.
The server-activated object has two activation modes (or WellKnownObjectMode values): Singleton and SingleCall.
The Singleton type will not have multiple instances at any time. If an instance exists, all client requests are serviced by the instance. If no instance exists, the server creates an instance, and all subsequent client requests are serviced by the instance. Because the Singleton type has an associated default lifetime, the client does not always receive a reference to the same instance of the Remotable class, even if no more than one instance is available at any time.
The SingleCall type always has only one instance for each client request. The next method call is serviced by another server instance, even if the previous instance has not been reclaimed by the system. The SingleCall type does not participate in the lifetime lease system.
To do an experiment with the two modes of server activation first, we make the following modifications to the remote object:
Using System;
Namespace RemoteObject
{
public class Myobject:marshalbyrefobject
{
private int i=0;
public int Add (int a,int b)
{
return a+b;
}
public int Count ()
{
return ++i;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.