本文发表在 rolia.net 枫下论坛The remoting object has one function:
private int m_nCount;
public string GetCount()
{
System.Threading.Thread.Sleep(500);
m_nCount++;
return m_nCount.ToString();
}
The Server is a sample remoting server and it should be fine.
The problem is in the client:
1. I have a client application like this
:
HttpChannel chan = new HttpChannel();
ChannelServices.RegisterChannel(chan);
RemotingConfiguration.RegisterWellKnownClientType(
typeof(Remoting.RemotingObject),
"http://localhost:8080/RemoteFunction");
RemotingObject obj = new RemotingObject();
Console.WriteLine(obj.GetCount());//run 10 times...
Console.WriteLine(obj.GetCount());
...
ChannelServices.UnregisterChannel(chan);
If I run two client application at almost same time, the result is like this:
instance 1: 1 2 4 6 8 10 ...
instance 2: 3 5 7 9 ...
both instance can run as expected, and they finished in almost same time ( 5s).
2. I put the remoting client into a aspx page, using almost exact same code:
RemotingConfiguration.RegisterWellKnownClientType(
typeof(Remoting.RemotingObject),
"http://localhost:8080/RemoteFunction");
obj = new RemotingObject();
this.Label1.Text=obj.GetCount(); //run 10 times.
this.Label1.Text=obj.GetCount();
...
The page is working, but if I access this page twice in almost same time, the first request will work, but the second request will return a "500 Internal Server Error".更多精彩文章及讨论,请光临枫下论坛 rolia.net
private int m_nCount;
public string GetCount()
{
System.Threading.Thread.Sleep(500);
m_nCount++;
return m_nCount.ToString();
}
The Server is a sample remoting server and it should be fine.
The problem is in the client:
1. I have a client application like this
:
HttpChannel chan = new HttpChannel();
ChannelServices.RegisterChannel(chan);
RemotingConfiguration.RegisterWellKnownClientType(
typeof(Remoting.RemotingObject),
"http://localhost:8080/RemoteFunction");
RemotingObject obj = new RemotingObject();
Console.WriteLine(obj.GetCount());//run 10 times...
Console.WriteLine(obj.GetCount());
...
ChannelServices.UnregisterChannel(chan);
If I run two client application at almost same time, the result is like this:
instance 1: 1 2 4 6 8 10 ...
instance 2: 3 5 7 9 ...
both instance can run as expected, and they finished in almost same time ( 5s).
2. I put the remoting client into a aspx page, using almost exact same code:
RemotingConfiguration.RegisterWellKnownClientType(
typeof(Remoting.RemotingObject),
"http://localhost:8080/RemoteFunction");
obj = new RemotingObject();
this.Label1.Text=obj.GetCount(); //run 10 times.
this.Label1.Text=obj.GetCount();
...
The page is working, but if I access this page twice in almost same time, the first request will work, but the second request will return a "500 Internal Server Error".更多精彩文章及讨论,请光临枫下论坛 rolia.net