InvokeServerMethodAsync
Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=4099
Printed Date: 13-May-2026 at 12:39am
Topic: InvokeServerMethodAsync
Posted By: jkattestaart
Subject: InvokeServerMethodAsync
Date Posted: 06-Apr-2013 at 2:18am
Hello,
I am using cocktail 1 with Silverlight and i want to send an email from the application. I found the InvokeServerMethodAsync but i'm not sure how to use this. The examples are not clear for me. I want to do something like:
EntityManager mgr = new AccoBookingEntities();
// Make async call
mgr.InvokeServerMethodAsync(new ServerMethodDelegate(EmailMessage.SendMail), InvokeServerMethodAsyncCompleted,_emailMessage);
the server call is:
[AllowRpc]
public static bool SendMail(EmailMessage emailMessage)
Is there a cocktail wrapper for this with something like an operationresult an how to use this....
Thx in advance
|
Replies:
Posted By: mgood
Date Posted: 06-Apr-2013 at 6:15am
|
There is no Cocktail wrapper for calling a server method beyond an overload of AsOperationResult to turn the result value of InvokeServerMethodAsync into an OperationResult. I've moved your post to the DevForce forum for help on the mechanics of calling a server method.
|
Posted By: kimj
Date Posted: 07-Apr-2013 at 3:13pm
DevForce requires that RPC methods have a specific signature, so your SendMail method would need to look like this:
[AllowRpc]
public static bool SendMail(IPrincipal principal, EntityManager em, params object[] args)
You can then get the EmailMessage from the args:
var emailMessage = args[0] as EmailMessage;
One other thing to watch out for: the EmailMessage must be a "known" type.
You can find more information here - http://drc.ideablade.com/xwiki/bin/view/Documentation/rsmc-query.
|
Posted By: jkattestaart
Date Posted: 08-Apr-2013 at 4:48am
|
Thx i got it working now!
|
|