spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / csharp / webservices / chap6 / 2 To page 1To page 2To page 3To page 4To page 5To page 6To page 7current page
[previous]

Professional C# Web Services

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

To see the sponsor in action we'll add a for loop to the Main() method in the file SimpleClient.cs. The time to sleep is longer than the configured RenewalTime, so we should see calls to the sponsor:

   for (int i=0; i < 20; i++)
   {
      DisplayLease("In loop: " + i, obj);
      obj.Hello();
      Thread.Sleep(25000);
   }

We have to change the configuration files and use the TcpChannel instead of the TcpClientChannel in the client configuration file SimpleClient.exe.config, because this channel has the functionality of both a client and server channel. If we start both the client and server application on the same system, we also have to configure a different port. Here I'm using port 9002, so we can run the application on a single system:

<channels>
   <channel ref="tcp" port="9002" />
</channels>

The server configuration file SimpleServer.exe.config needs a similar change:

<channels>
   <channel ref="tcp" port="9000" />
</channels>

Running the Example

The console output of the client application in the screenshot below lists the lease times of the remote object. The first line shows a lease time value that is near to 60 seconds; this was the initial lease time. 25 seconds later the second iteration of the loop happened. The garbage collection doesn't happen immediately after the time 0 is reached, so the remote object was lucky that the lease time was extended twice to 20 seconds after a wait (loops 2 and 3), but the Renewal() method still wasn't called. Before loop 4, the Renewal() method was called for the first time, and here the lease was extended to the value that the sponsor supports, 2 minutes. The lease time again is decremented, before Renewal() is called again before loop 10:

Results of sponsor example

Remote Object Types Summary

We have now seen the types of the remote objects and their purpose. Let's summarize the features of these objects in the following table.

Object Type Time of Object Activation State Leasing
Well-known SingleCall With every method call Stateless No
Well-known Singleton Only once with the first method call State shared for all clients Yes
Client-Activated When the client instantiates the remote object State Yes

home / programming / csharp / webservices / chap6 / 2 To page 1To page 2To page 3To page 4To page 5To page 6To page 7current page
[previous]


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Installing and Using Meeplace, the Business Review CMS · Sending an HTML and Plain Text E-newsletter with ASP.NET, Part 2 · Create Multilingual Web Sites with Windows Unicode Fonts
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Top 10 Threats to Wireless Security · Poll: UC Uptake on the Rise · Review: Fluke AirCheck Wi-Fi Tester 1.0

Created: February 25, 2002
Revised: February 25, 2002


URL: http://webreference.com/programming/csharp/webservices/chap6/2/8.html