home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / dotNETSDK / SETUP.EXE / netfxsd1.cab / FL_HelloAsync_cs________.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Encoding:
Text File  |  2001-03-21  |  2.3 KB  |  65 lines

  1. /*=====================================================================
  2.  
  3.   File:      HelloAsync.cs
  4.  
  5. ---------------------------------------------------------------------
  6. This file is part of the Microsoft .NET Framework SDK Code Samples.
  7.  
  8.   Copyright (C) Microsoft Corporation.  All rights reserved.
  9.  
  10. This source code is intended only as a supplement to Microsoft
  11. Development Tools and/or on-line documentation.  See these other
  12. materials for detailed information regarding Microsoft code samples.
  13.  
  14. THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  15. KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  16. IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  17. PARTICULAR PURPOSE.
  18. =====================================================================*/
  19.  
  20. using System;
  21. using System.Runtime.Remoting;
  22. using System.Runtime.Remoting.Messaging;
  23. using System.Threading;
  24.  
  25. using Hello;
  26.  
  27. public class HelloAsync
  28. {
  29.     public static void Main(String[] args)
  30.     {
  31.         Console.WriteLine(".NET Remoting Sample - HelloAsync");
  32.         Console.WriteLine("---------------------------------\n");
  33.  
  34.         HelloAsync helloAsync = new HelloAsync();
  35.         helloAsync.Run();
  36.     }
  37.  
  38.     public void Run()
  39.     {
  40.         String name = "Bill";    
  41.         String configFilename = "HelloAsync.exe.config";
  42.  
  43.         Console.WriteLine("Configuring Remoting from {0}", configFilename);
  44.         RemotingConfiguration.Configure(configFilename);
  45.  
  46.         Console.WriteLine("Obtaining Proxy for HelloService, using new");
  47.         HelloService helloService = new HelloService();
  48.  
  49.         Console.WriteLine("Creating ReturnGreetingDelegate to HelloService.ReturnGreeting");
  50.         ReturnGreetingDelegate returnGreetingDelegate = new ReturnGreetingDelegate(helloService.ReturnGreeting);
  51.  
  52.         Console.WriteLine("Calling returnGreetingDelegate.BeginInvokeInvoke");
  53.         IAsyncResult ar = returnGreetingDelegate.BeginInvoke(name, null, null);
  54.  
  55.         Console.WriteLine("Calling returnGreetingDelegate.EndInvoke");
  56.         String greeting = returnGreetingDelegate.EndInvoke(ar);
  57.  
  58.         Console.WriteLine("returnGreetingDelegate.EndInvoke returned: {0}", greeting);
  59.     }
  60.  
  61.     public delegate String ReturnGreetingDelegate(String name);
  62.  
  63. }
  64.  
  65.