I have a WCF service as below
public bool RefreshDB()
{
if (twcPMRefresh())
status = true;
if (twcCommonRefresh())
status = true;
}
The logic inside the methods twcPMRefresh() and twcCommonRefresh() is asynchronous and hence I want to wait till 'twcPMRefresh' exceution is finished execution and then invoke twcCommonRefresh. Both the methods are more are less like below.
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
}
Can please assist on this. Thanks!!
You can use the await async
method:
Assuming your twcPMRefresh()
and twcCommonRefresh()
methods are both ASYNC you can write it like this:
public async bool RefreshDB()
{
if (await twcPMRefresh())
status = true;
if (await twcCommonRefresh())
status = true;
}
your method RefreshDB()
can now be called either way:
bool result = RefreshDB().Result()
bool result = await RefreshDB(); //Needs an async Method or a task to be used.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.