[英]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.