remoting和事件
public class RemoteServer : MarshalByRefObject
{
public delegate void MyEventHandler(object sender,MyEventArgs e);
public event MyEventHandler MyEvent;
public RemoteServer()
{
Console.WriteLine( "RemoteServer activated ");
}
public void SyncCache()
{
OnMyEvent(new MyEventArgs(0));
}
protected void OnMyEvent(MyEventArgs e)
{
if (MyEvent!=null)
{
MyEvent(this,e);
}
}
}
服务器
//tcp channel
....
ChannelServices.RegisterChannel(Ch);RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemotingCore.RemoteServer), "WebService.ClearCache ", WellKnownObjectMode.SingleCall);
问题是: 我想把它的事件和服务器上另一个类A的方法关联,就是说客户端调用remoting object的方法相当于调用了类A的方法.
但现在看到的sample都是只能在客户端才能处理事件.怎么能在服务器就能处理事件.
[解决办法]
我来我来JFJF