This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!
Async Programming Tasks
Calling an Async method
using System;
using System.Runtime.Remoting;
using System.Threading;
using HelloService;
public class SimpleHello
{
public static ManualResetEvent evt;
public static void Main(String[] args)
{
evt = new ManualResetEvent(false);
SimpleHello simpleHello = new SimpleHello();
simpleHello.InstanceMain(args);
evt.WaitOne();
}
public void HelloCallBack(IAsyncResult ar)
{
HelloDelegate helloDelegate = (HelloDelegate)ar.AsyncObject;
String result = helloDelegate.EndInvoke(ar);
Console.WriteLine("Hello.HelloMethod returned: " + result);
evt.Set();
}
public delegate String HelloDelegate(String name);
public void InstanceMain(String[] args)
{
String name = "Bill";
RemotingServices.ConfigureRemoting("MyHello.cfg");
//RemotingServices.ConfigureRemoting("MyHello.DirectHTTP.cfg");
Hello hello = new Hello();
AsyncCallback asyncCallback = new AsyncCallback(this.HelloCallBack);
HelloDelegate helloDelegate = new HelloDelegate(hello.HelloMethod);
IAsyncResult ar = helloDelegate.BeginInvoke(name, asyncCallback, null);
}
}