Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/292.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.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# 为什么可以';我不能使用AsyncMethodCaller吗?_C#_Multithreading_.net 3.5 - Fatal编程技术网

C# 为什么可以';我不能使用AsyncMethodCaller吗?

C# 为什么可以';我不能使用AsyncMethodCaller吗?,c#,multithreading,.net-3.5,C#,Multithreading,.net 3.5,这是我第一次使用需要通过回调方法将值返回给另一个类的线程。我已经读过了,似乎每个人都在使用AsyncMethodCaller。然而,尽管我已经为我的项目添加了必要的参考,VS2008认为它是未定义的。。。我在这里还可能做错什么?我在MSDN文档中没有看到AsyncMethodCaller,除了作为这里一些示例代码的一部分(您自己定义AsyncMethodCaller委托): 下面是部分代码(请参见链接了解整个示例): 哦,天哪。谢谢你接电话。我没有意识到在本文前面的不同部分中定义了委托!多么尴

这是我第一次使用需要通过回调方法将值返回给另一个类的线程。我已经读过了,似乎每个人都在使用AsyncMethodCaller。然而,尽管我已经为我的项目添加了必要的参考,VS2008认为它是未定义的。。。我在这里还可能做错什么?

我在MSDN文档中没有看到AsyncMethodCaller,除了作为这里一些示例代码的一部分(您自己定义AsyncMethodCaller委托):

下面是部分代码(请参见链接了解整个示例):


哦,天哪。谢谢你接电话。我没有意识到在本文前面的不同部分中定义了委托!多么尴尬啊!)
using System;
using System.Threading; 

namespace Examples.AdvancedProgramming.AsynchronousOperations
{
    public class AsyncDemo 
    {
        // The method to be executed asynchronously.
        public string TestMethod(int callDuration, out int threadId) 
        {
            Console.WriteLine("Test method begins.");
            Thread.Sleep(callDuration);
            threadId = Thread.CurrentThread.ManagedThreadId;
            return String.Format("My call time was {0}.", callDuration.ToString());
        }
    }
    // The delegate must have the same signature as the method
    // it will call asynchronously.
    public delegate string AsyncMethodCaller(int callDuration, out int threadId);
}