-
-
Save breezhang/2146363 to your computer and use it in GitHub Desktop.
Client just for test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyRemoteClass : MarshalByRefObject, IMyInterface | |
{ | |
public int FunctionOne(string str) | |
{ | |
return str.Length; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Client some stuff | |
namespace Client | |
{ | |
using System; | |
using System.Runtime.Remoting; | |
using System.Runtime.Remoting.Channels; | |
using System.Runtime.Remoting.Channels.Tcp; | |
using System.Runtime.Remoting.Messaging; | |
using ClientA; | |
static class MyClient | |
{ | |
private delegate int MyDelegate(string s); | |
public static void Main() | |
{ | |
var mTcpChan = new TcpChannel(9999); | |
ChannelServices.RegisterChannel(mTcpChan); | |
RemotingConfiguration.RegisterWellKnownServiceType( | |
Type.GetType("ClientA.MyRemoteClass,ClientA"), | |
"FirstRemote", WellKnownObjectMode.SingleCall); | |
// ChannelServices.RegisterChannel(m_TcpChan); | |
var m_RemoteObject = (IMyInterface) | |
Activator.GetObject(typeof(IMyInterface), | |
"tcp://vivi-pc:9999/FirstRemote"); | |
var m_delegate = | |
new MyDelegate(m_RemoteObject.FunctionOne); | |
m_delegate.BeginInvoke("Amazing", | |
new AsyncCallback(MyCallBack), null); | |
System.Console.WriteLine("Press ENTER to quit"); | |
System.Console.ReadLine(); | |
} | |
private static void MyCallBack(IAsyncResult ar) | |
{ | |
int l = ((MyDelegate)((AsyncResult)ar).AsyncDelegate).EndInvoke(ar); | |
Console.WriteLine(l); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment