1
我有WCF服務公開,驗證參數並真實/錯誤地返回並運行後臺線程來處理結果。對於我曾嘗試與HostingEnvironment.QueueBackgroundWorkItem做到這一點,但它給了我下面的錯誤:下面後臺線程與WCF中的HostingEnvironment.QueueBackgroundWorkItem
Operation is not valid due to the current state of the object.
代碼給出:
public class SearchService : ISearchService
{
public async Task<bool> SearchAsync(UserSearch search, string email)
{
//Some operations
var searchManager = new SearchManager();
HostingEnvironment.QueueBackgroundWorkItem(ct => searchManager.PerformSearch(search, email));
return true;
}
}
任何codez顯示? [MCVE] – MickyD