Oracle 使用WCF异步
我有一个依赖单向WCF服务的Windows窗体应用程序;它只是从(Oracle)数据库返回数据。 有些客户端对wcf的调用是长时间运行的,现在我们需要实现一种异步捕获Oracle的DBMS_输出并将其发送到客户端的方法。 如何使用连接到WCF的信号器或类似设备来实现这些功能?Oracle 使用WCF异步,oracle,wcf,signalr,.net-4.5,xsockets.net,Oracle,Wcf,Signalr,.net 4.5,Xsockets.net,我有一个依赖单向WCF服务的Windows窗体应用程序;它只是从(Oracle)数据库返回数据。 有些客户端对wcf的调用是长时间运行的,现在我们需要实现一种异步捕获Oracle的DBMS_输出并将其发送到客户端的方法。 如何使用连接到WCF的信号器或类似设备来实现这些功能? 我们正在使用.NET framework 4.5。因为在问题中标记了XSockets 我会在客户端订阅一个主题,并让实时框架在长时间运行的任务完成后发布结果 有关如何将WCF提升为实时的简单示例,请参见: 该示例只是立即发
我们正在使用.NET framework 4.5。因为在问题中标记了XSockets 我会在客户端订阅一个主题,并让实时框架在长时间运行的任务完成后发布结果 有关如何将WCF提升为实时的简单示例,请参见: 该示例只是立即发布一个结果,但是如果在XSockets中调用的方法启动了一个长时间运行的任务,并在完成后发布结果,则在工作完成时将通知客户端 从WCF(或另一个半双工进程)调用XSockets控制器只需两行代码
因为XSockets在问题中被标记了 我会在客户端订阅一个主题,并让实时框架在长时间运行的任务完成后发布结果 有关如何将WCF提升为实时的简单示例,请参见: 该示例只是立即发布一个结果,但是如果在XSockets中调用的方法启动了一个长时间运行的任务,并在完成后发布结果,则在工作完成时将通知客户端 从WCF(或另一个半双工进程)调用XSockets控制器只需两行代码
因为XSockets在问题中被标记了 我会在客户端订阅一个主题,并让实时框架在长时间运行的任务完成后发布结果 有关如何将WCF提升为实时的简单示例,请参见: 该示例只是立即发布一个结果,但是如果在XSockets中调用的方法启动了一个长时间运行的任务,并在完成后发布结果,则在工作完成时将通知客户端 从WCF(或另一个半双工进程)调用XSockets控制器只需两行代码
因为XSockets在问题中被标记了 我会在客户端订阅一个主题,并让实时框架在长时间运行的任务完成后发布结果 有关如何将WCF提升为实时的简单示例,请参见: 该示例只是立即发布一个结果,但是如果在XSockets中调用的方法启动了一个长时间运行的任务,并在完成后发布结果,则在工作完成时将通知客户端 从WCF(或另一个半双工进程)调用XSockets控制器只需两行代码
@kims的回答是正确的,但为了进一步解释,我将添加一个控制器示例。 只是显示工作可以开始,然后稍后会发布一条消息
/// <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...
}
}
//
///实时控制器
///
公共类ZooController:XSocketController
{
///
///此方法将从JavaScript、WCF和MVC示例中找到
///也可以发送一个自定义对象,但在本例中是一个字符串。
///
///
公共消息(字符串消息)
{
//只需发送给所有订户
this.SendToAll(新的{message=“Longrunning进程已启动”},“say”);
睡眠(10000);
SendToAll(new{message},“say”);
//你也可以使用
//这个。发送,这个。发送等。。。
}
}
编辑:我不知道您的场景,但也许您可以使用所述的longrunning控制器选项@kims的答案是正确的,但为了进一步解释,我将添加一个控制器示例。 只是显示工作可以开始,然后稍后会发布一条消息
/// <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...
}
}
//
///实时控制器
///
公共类ZooController:XSocketController
{
///
///此方法将从JavaScript、WCF和MVC示例中找到
///也可以发送一个自定义对象,但在本例中是一个字符串。
///
///
公共消息(字符串消息)
{
//只需发送给所有订户
this.SendToAll(新的{message=“Longrunning进程已启动”},“say”);
睡眠(10000);
SendToAll(new{message},“say”);
//你也可以使用
//这个。发送,这个。发送等。。。
}
}
编辑:我不知道您的场景,但也许您可以使用所述的longrunning控制器选项@kims的答案是正确的,但为了进一步解释,我将添加一个控制器示例。 只是显示工作可以开始,然后稍后会发布一条消息
/// <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...
}
}
//
///实时控制器
///
公共类ZooController:XSocketController
{
///
///此方法将从JavaScript、WCF和MVC示例中找到
///也可以发送一个自定义对象,但在本例中是一个字符串。
///
///
公共消息(字符串消息)
{
//只需发送给所有订户
this.SendToAll(新的{message=“Longrunning进程已启动”},“say”);
睡眠(10000);
SendToAll(new{message},“say”);
//你也可以使用
//这个。发送,这个。发送等。。。
}
}
编辑:我不知道您的场景,但也许您可以使用所述的longrunning控制器选项@kims的答案是正确的,但为了进一步解释,我将添加一个控制器示例。 只是显示工作可以开始,然后稍后会发布一条消息
/// <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...
}
}
//
///实时控制器
///
公共类ZooController:XSocketController
{
///
///此方法将从JavaScript、WCF和MVC示例中找到
///也可以发送一个自定义对象,但在本例中是一个字符串。
///
///
公共消息(字符串消息)
{
//只需发送给所有订户
this.SendToAll(新的{message=“Longrunning进程已启动”},“say”);