Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将代码从框架4.0转换为3.5_C#_.net_Multithreading - Fatal编程技术网

C# 将代码从框架4.0转换为3.5

C# 将代码从框架4.0转换为3.5,c#,.net,multithreading,C#,.net,Multithreading,我将一些应用程序从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; Thread

我将一些应用程序从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?

使用class
ManualResetEvent
代替class
ManualResetEventSlim
问题是什么?ManualResetEventSlim是一种4.0方法。如何将其改写为3.5行。但是mre呢。等等(毫秒计时)?ManualResetEvent没有等待方法我想你可以使用WaitOne,它等效吗?好的,我试试这个