I have a Windows forms application that depends on oneway WCF service ; which simply returns data from (Oracle) Database. Some of client calls to wcf are long running, now we need to implement a way to asynchronously capture and send Oracle's DBMS_output to the client. How can such be implemented using SignalR or similar that can be hooked to WCF ? We are using .NET framework 4.5.
-
i would think doing the usual async method in the service, and the client using a callback, would work. you probably want a sufficient connection pool also. A simple example [here](http://msdn.microsoft.com/en-us/library/ms730059%28v=vs.110%29.aspx) – tbone Apr 12 '14 at 13:30
2 Answers
@kims answer is correct, but to explain further I will add a sample of the controller. Just showing that work can start and then later a message will be published...
/// <summary>
/// A realtime controller
/// </summary>
public class ZooController : XSocketController
{
/// <summary>
/// This method will be hit both from JavaScript, WCF and MVC examples
/// Could have sent a custom object as well, but settled for a string in this case.
/// </summary>
/// <param name="message"></param>
public void Say(string message)
{
//Just send it out to all subscribers
this.SendToAll(new {message = "Longrunning process started"}, "say");
Thread.Sleep(10000);
this.SendToAll(new {message}, "say");
//You can also use
//this.Send, this.SendTo<T> etc...
}
}
EDIT: I do not know your scenario, but maybe you can use the longrunning controller options described here

- 2,275
- 1
- 13
- 9
Since XSockets was tagged in the question...
I would subscribe to a topic in the client and let a realtime framework publish the result when the long running task is completed.
A simple sample on how to boost a WCF to realtime can be found here: XSockets WCF That sample just publish a result instantly, but if the method called in XSockets starts a long running task and publish the result upon completion the client will be notified when the work is done.
It is only two lines of code to call a XSockets controller from a WCF (or another half duplex process)
//Get a connection (if it exists already that one will be used)
var conn = ClientPool.GetInstance("ws://127.0.0.1:4502/Zoo", "*");
//We send an anonymous message here, but any object will work.
conn.Send(new { message = "I was sent over WebSockets: " + message },"Say");

- 256
- 1
- 5