Wednesday, March 15, 2006

 

Remoting event callbacks

I recently had need to add an event call back from a remote object. I got it working with help from several useful articles, but mainly this
on Code Project.
Some tweaks I made were putting all the remoting setup bits and pieces in config files, but the most important was that I changed the server code so that rather than just raising the event it iterates through the event invocation list and invokes each delegate. This is because I noticed that if a client disappears without removing its event call back from the list the server would fail whenever the event was raised. By iterating the invocation list you can catch the offending delegate and handle it more gracefully (i.e. so that the clients don't all error and removing the orphaned delegate from the invocation list)
e.g.

Delegate[] invocationList = MyEvent.GetInvocationList();

foreach(Delegate d in invocationList)
{
try
{
d.DynamicInvoke(new object[] {sessionId, trackNumber});
}
catch(System.Reflection.TargetInvocationException ex)
{
//the invocation failed.
//If the cause was that the service could not be found then
//remove the delegate from the invocation list
if (ex.InnerException.Message == "Requested Service not found")
{
MyEvent= (MyEventHandler)MyEventHandler.Remove(MyEvent, d);

//log the error
}
else
{
//otherwise rethrow the exception
throw(ex);
}
}
}

Comments:
howdy randomatic.blogspot.com admin found your blog via Google but it was hard to find and I see you could have more visitors because there are not so many comments yet. I have discovered website which offer to dramatically increase traffic to your blog http://xrumer-service.com they claim they managed to get close to 4000 visitors/day using their services you could also get lot more targeted traffic from search engines as you have now. I used their services and got significantly more visitors to my website. Hope this helps :) They offer best services to increase website traffic Take care. Jeremy
 
Heya just wanted to give you a quick heads up and let you know a few of the pictures aren't loading properly. I'm not sure
why but I think its a linking issue. I've tried it in two different internet browsers and both show the same results.

Also visit my blog: xerox 8560 dn
 
Greetings from Idaho! I'm bored to death at work so I decided to browse your blog on my iphone during lunch break. I enjoy the information you present here and can't
wait to take a look when I get home. I'm surprised at how fast your blog loaded on my mobile .. I'm not even using WIFI, just 3G
.. Anyhow, fantastic site!

Take a look at my blog post :: http://whyilovepets.com/blogs/entry/Xerox-Phaser-8560-Review
 
Download file setup HP LaserJet P1005.

Here is my site; http://Www.nepalmelbourne.com/
 
Oh, and the music was ideal for it too, good job
Nick!

My blog post; ,cheap earrings for women
 
Exceptional. This obtained my Lexmark e210 working.
It is constantly a challenge in Windows to obtain this printer working, this is the 3rd driver I have actually had to use for many years.


Feel free to surf to my web-site ... mllekarensofie.wordpress.com
 
Nice weblog here! Also your site quite a bit up very fast!
What web host are you using? Can I am getting your affiliate hyperlink
for your host? I wish my web site loaded up as
fast as yours lol

my website: http://www.5dsmartstore.com/pet-care/treat-your-kitty-with-the-sureflap-microchip-cat-flap/
 
Thanks for sharing your thoughts on ziggo dome amsterdam address.
Regards

Look at my blog post - how to get rid of acne
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?