Hi,
I have got some problem with sending of events in .NET.
I am using remouting.
The client has got 2 objects for receiving different types of events
(responses and events)
The server has got two objects for sending of these events.
The client opens tcp port 0 to receive events:
if (ChannelServices.GetChannel("tcp") == null)
{
BinaryClientFormatterSinkProvider provider = new
BinaryClientFormatterSinkProvider();
IDictionary props = new Hashtable();
props["port"] = 0;
TcpChannel chan = new TcpChannel(props, provider, null);
ChannelServices.RegisterChannel( chan );
}
and the client supplies to the server 2 delegates for the different kinds of
the events. These callbacks are added to an event table.
When the event or the response occured , it is being sent to the client
from the thread corresponding to the event or response object.
The problem occurs when the server is sending simultaneously response and
event to the same client (from the different thread).
The client receives only the response (that is sent the first always). The
event is seems to be stuck in the delegate callback:
...........
printDebugMsg(string.Format("before sending of event
{0}",eventData.eventType));
cbDelegateEvent(obj,eventData);
printDebugMsg(string.Format("after sending of event
{0}",eventData.eventType));
............
I am receiving something like the following :
before sending of event RESPONSE
before sending of event EVENT
after sending of event RESPONSE.
And it's all.
I have added debug printings on the client side and saw that the event does
not arrive to the client at all.
After the client was disconnected from the server , it(the client) received
all the relevant stuck events.
I fixed the problem by synchronization of the response and event threads
thus that only one call to the client side can be processed at the same
time.
Cannot I send 2 events from the 2 threads to the same client at the same
time?
I wouldn't want to use synchronization. Maybe there is another solution
(something with RegisterChannel )?
Thanks
Efim