Options for Async Silverlight-to-WPF communication? - wpf

What's the fastest communication model for a Silverlight component communicating with a WPF component? That is, at the very least I'd like to consume an event from a Silverlight component in a WPF component.
I understand you can use WCF to build a bridge
I understand you can use Javascript to bridge from WPF -> Silverlight (and I have that working)
I understand you can use COM to go the other way (Silveright -> WPF)
However I'm looking for a tighter communication model (not using COM) - perhaps like EventAggregator (Silverlight component pubs, WPF component subs)...but I've only seen eventAggregation in WPF or Silverlight but not both at the same time.
Any ideas for creating such an eventAgg / eventBus, without using WCF, without using COM?
Open to any approaches / ideas; might be something I haven't considered.
Thanks.

Interesting challenge - could you provide a little more detail on why you need to do this?
My first question is: Are you envisioning these two apps running on the same machine, at the same time? Both are important.
If the answer is yes (same machine, both running) then you should be able to implement a solution using WCF, with the service self-hosted in the WPF app, the Silverlight client referencing it, and a cross-domain policy setup appropriately.
If the answer is yes, but not at the same time, then you'll need a third party, like a Message Bus, perhaps implemented as a Windows Service. NServiceBus comes to mind.
In any case, WCF really is the best solution for messaging in Silverlight. If you were going Silverlight app-to Silverlight app there is a mechanism for that that doesn't require WCF.
A message bus would give you the Event Aggregator functionality you're thinking of - a player who is always there to accept subscriptions and publications.
Another option (if running at the same time) is to elevate your Silverlight app to full-trust and use Sockets. See this link for more info (he provides an example that may be helpful).

Related

WCF between WinForms applications

I have two WinForms applications that need to communicate.
I'm thinking about using WCF to establish communication between those two, but converting one of them WCF service application is not an option.
Is there a way to implement the WCF somehow or should I forget about it?
For example I thought of creating a WCF server (with Push and Pull mechanisms) that both applications could use, but I don't think it's very efficient.
Moreover, consider that the users cannot have administrative privileges, if this helps proposing other solutions.
Main idea is create an WCF service hosted in a Winform or an Console application. Than you should add the WCF service reference to your Winform applications References. Rest is simple. You may query the service in a timer say 500ms. This whole consept may help you. If you want to see an implemented example see the link below:
Have you seen: http://wcfsimplechat.codeplex.com/ . This little WCF Chat sample can help i think.

Silverlight EAP vs APM to WCF Services

I am building a Silverlight application that uses Web Services.
I have an ServiceAgent calls that is used to hide the proxy implementation from my ViewModels.
My question is which Asynchronous programming model is best used for Silverlight applications? That is, should I use Event base Async pattern (EAP) OR Async Programming Model (APM)?
Please let me know which has worked best for you in the past.
The rule of thumb is to implement the EAP when it is being used by UI code and the APM for back-end or library services.
I guess in your case, having events raised on the UI thread would be useful, so I would choose the EAP.
You might also want to consider using the new TAP: Task-based Asynchronous Pattern. This would make it easier to port to C#5 async when it is released later this year.
UPDATE:
I should have recommended using TaskFactory.FromAsync since you are wrapping an existing APM.

Creating basic push-style notification app using WPF and WCF?

I'm an asp.net developer with very little experience in WPF. I'm looking to create a very basic application, one that would be distributed to a couple clients and allow any given client to send a basic message to all of the others running the application.
I'm not exactly sure where to start or what to look for, being that I'm new to the WPF world. Could someone point me in the direction I need? Would it involve MSMQ? I'd like to stay away from polling if possible, but what generally would I need to know to get started? Thanks.
You could take advantage of the classes in the System.Net.PeerToPeer Namespace.
I did some push notification with WPF and WCF in 2006 using the framework classes from .NET 3.0 which were deprecated by System.Net.PeerToPeer in .NET 3.5 / 4.0, but the old system worked well, so I can only assume that the new classes in the framework are even better :-)
We used push notifications for the majority of data that didn't matter if it was missed by a client, but MSMQ for sending important occasional messages that absolutely could not be lost. You don't necessarily need MSMQ though - we were running mission-critical apps which demanded it, so we played it safe.
Click here to read the MSDN Magazine article that was published to introduced the new P2P namespace in 2007.

silverlight / wpf two way communication with server side app

I have business logic in one application, let's call it "server". I want to "observe" what's going on in this application using a silverlight or WPF app.
So I've figured, I will use WCF services that expose current state to my clients, and I will poll for updates on a regular basis.
It's working well, but I need some kind of two way communication, because I need to notify my clients about changes.
Is there any other way than polling?
For Silverlight, there is a PollingDuplex mode, which still results in polling, but has a somewhat easier API to work with than dealing with the polling yourself.
See this article on MSDN : http://msdn.microsoft.com/en-us/library/cc645027(VS.95).aspx
For WPF, I believe there are more efficient ways to do this, but I'm not as familiar with the full WCF stack.
http://msdn.microsoft.com/en-us/library/ms731064.aspx

What are the methods of communication between Silverlight and server side?

Background:
I have basically no experience in Silverlight, i was asked to start reading up on the tech and provide some insight for client which may want to rebuild the UI of their .Net Desktop application in silverlight. So my experience is what i have been able to google (which surprisingly is not easy) and the few tutorials i have done.
I am aware Silverlight could use ASMX Web Service , WCF Services or REST to do communications with the server.
Question:
Are there any other official or non-official mothods of communication anyone knows of?
Thank you in advance,
David
Start here:
http://msdn.microsoft.com/en-us/library/dd470099(VS.95).aspx
http://videos.visitmix.com/MIX08/T13
http://videos.visitmix.com/MIX09/T42F
I am somewhat biased having worked on the technology :), but I would urge you to consider WCF.
This method gives you great usability: It literally takes a few minutes to "Add New... Silverlight-enabled WCF Service" to your project and have everything up-and-running. In Silverlight 3, this uses a very performant binary XML protocol under the covers, which can be easily switched to regular text XML for debuging with just a 2-line config change. And it integrates nicely with most authentication models that you would want (see the security section in the doc link above).
Of course, you can roll-your-own communication using HttpWebRequest, WebClient, or even sockets. Using WebClient is probably best if you want to go with REST on the server. Keep in mind that some things that are normally possible in REST (such as using PUT and DELETE HTTP verbs) are not possible in browser plugins such as Flash and Silverlight due to browser restrictions.
Finally, there's .NET RIA Services. It's a bit too heavy-weight for some scenarios and doesn't have some of the WCF features (like binary and duplex), but it's more than just a way to communicate with the server: It gives you a whole perscriptive framework for building SL apps with server-side data, and gives you a lot of nice features like validation, paging, etc. for free.

Resources