I’m working with a webservice in WP7, but I get some syntax I have never seen before, and would like to read about them before I start with implementing this webmethods, without even knowing what I’m doing. I have tried to find some pages about it, but can’t find anything about the client side, only how to create a webservice. First I wanted to just call the method, which had a string as return type, but was represented as a void. After some searching, I figured out that you have to get a response from the server, which will fire an evenListener( or something, correct me if I’m wrong ). But this EventListener has an object return type, never seen this before. So I could just go wild and either literally copy-paste the project where it is used, or go nuts and try finding it out by trial-and-error, but I’d rather read in on the subject.
I have a project where it is implemented:
_channel.ShellToastNotificationReceived += (s, e) => Deployment.Current.Dispatcher.BeginInvoke(() => ToastReceived(e));
Does anyone have a link where this is explained in detail?
This is a lambda-expression, used as an event handler. Lambda-expressions were introduced in C# 3.0 and cannot only be used for iterations, expressions and statements but also for event handlers. Here’s an article that explains how you go from named methods with delegate instantiation to the lambda event handler: Lambda Expressions in 5 Minutes.
In short you go from:
to:
Hope this helps! 😉