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
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

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]

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

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

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

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


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