Reputation:
public static void StartService()
{
Hashtable t = new Hashtable();
t["port"] = portnumber;
t["name"] = "somechannel";
channel= new TcpChannel(t, null, null);
ChannelServices.RegisterChannel(channel, false);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(someRemoteObject), "somedomain", WellKnownObjectMode.SingleCall);
}
public static void StopService()
{
//what should I do ??
}
buttonStart_Click
: calls StartService()
buttonStop_Click
: calls StopService()
It's obvious that clicking buttonStart
twice make "Only one usage of each socket address (protocol/network address/port) is normally permitted" exception.
the question is how stop responding to remote calls without terminating the application.
Upvotes: 0
Views: 1326
Reputation: 161821
How about you just set a flag the first time buttonStart_Click is called, and if the flag is set, skip the remoting stuff?
Upvotes: 2