我将一些应用程序从 Framework 4.0 转换为 3.5,并且下一个代码有问题:
public virtual bool TryToGetResponse(out string response, int millisecondsTimeout) {
var mre = new System.Threading.ManualResetEventSlim(false);
string resp = response = null;
ThreadPool.QueueUserWorkItem(_ => {
resp = GetResponse();
mre.Set();
});
if (mre.Wait(millisecondsTimeout)) {
response = resp;
return true;
} else
return false;
}
这如何转换为 3.5?