0
我有一個WCF服務如下等待異步方法在c#調用
public bool RefreshDB()
{
if (twcPMRefresh())
status = true;
if (twcCommonRefresh())
status = true;
}
方法twcPMRefresh()和twcCommonRefresh(內部的邏輯)是異步的,因此我想等到「twcPMRefresh」 exceution是執行完畢 ,然後調用twcCommonRefresh。這兩種方法都不如下圖。
public bool twcPMRefresh()
{
tweets=await
(from tweet in GetTwitterContext(localProxyIP,fCode).Status
where tweet.Type == StatusType.User &&
select tweet)
.ToListAsync();
--use 'tweets' list to insert in database
}
請幫助。謝謝!!
你可以使用TPL並使用'Task.ContinueWith'調用。 – Tdorno
在RefreshDB()方法中建議任務continueWith?我嘗試了下面的方式,但仍然沒有運氣。語法中有什麼錯誤嗎? var firstTask = new Task(()=> twcPMRefresh()); var secondTask = firstTask.ContinueWith((t)=> twcCommonRefresh()); firstTask.Start(); –
如果您顯示兩種方法的簽名,那將會很棒。 – Enigmativity