public void SyncCall() { string serviceUrl = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"]; RemoteObject.MyObject app = (RemoteObject.MyObject)Activator.GetObject(typeof(RemoteObject.MyObject), serviceUrl); Response.Write("[Sync]app.Add(18, 22) = " + app.Add(18, 22) + "<br/>"); }
static void Main(string[] args) { RemoteObject.MyObject app = (RemoteObject.MyObject)Activator.GetObject(typeof(RemoteObject.MyObject), System.Configuration.ConfigurationSettings.AppSettings["ServiceURL"]); Console.WriteLine(app.Add(1, 2)); Console.ReadLine(); }
public void AsyncCall() { //e = new ManualResetEvent(false); try { string serviceUrl = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"]; RemoteObject.MyObject app = (RemoteObject.MyObject)Activator.GetObject(typeof(RemoteObject.MyObject), serviceUrl); AsyncCallback RemoteCallback = new AsyncCallback(this.OurRemoteAsyncCallBack); RemoteAsyncDelegate RemoteDel = new RemoteAsyncDelegate(app.TimeConsumingRemoteCall); IAsyncResult RemAr = RemoteDel.BeginInvoke(RemoteCallback, null); Response.Write("Async Function calling... "); RemAr.AsyncWaitHandle.WaitOne(); } catch (Exception) { } }