









//同步方法调用异步方法
public static string Test(string cName)
{
AutoResetEvent autoResetEvent = new AutoResetEvent(false);
ThreadPool.QueueUserWorkItem(async (str) =>
{
var custom = cusService.SelectOne(c => c.CUSTOM_NAME == cName).GetAwaiter().GetResult();
autoResetEvent.Set(); // 工作完成后设置信号
}
var b = autoResetEvent.WaitOne(); // 等待信号
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。