[英]call event asynchronously in wcf service
我正在实施第三方服务以获取一些提要。 下面的示例代码。 当我调用GetLiveFeed函数时,响应是通过事件HandleEvent返回的。
public class WebComponent
{
public string livefeed = string.Empty;
public static string GetSerivceRequest()
{
WebComponent obj = new WebComponent();
obj.GetResult();
return obj.livefeed;
}
public void GetResult()
{
Service abc = new Service();
abc.GetLiveFeed();
}
public void HandleEvent(Event eventObj)
{
livefeed = "Value from third party service";
}
}
我想在静态函数Getservice中等待,直到引发事件并在livefeed变量中分配了值。 但是截至目前,我只获得了空白的价值。 如果我把thread.sleep比我得到我不想使用的价值
我能够使用AutoresetEvent功能使父线程等到子线程中的执行完成
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.