我正在研究新的 Async CTP 并研究一些示例代码,
我遇到了这段代码:
public async void button1_Click(object sender, EventArgs e)
{
string text = txtInput.Text;
await ThreadPool.SwitchTo(); // jump to the ThreadPool
string result = ComputeOutput(text);
string finalResult = ProcessOutput(result);
await txtOutput.Dispatcher.SwitchTo(); // jump to the TextBox’s thread
txtOutput.Text = finalResult;
}
请问我在哪里可以找到 ThreadPool.SwitchTo? SwithcTo 方法不在 ThreadPool 类上
我有一个 AsyncCtpLibrary.dll 的引用......但运气不好
最佳答案
作为引用,CharlesO 在上面的评论中回答了他的问题:
OK, found it guys, Summary: Provides methods for interacting with the ThreadPool. Remarks: ThreadPoolEx is a placeholder.
Public Shared Function SwitchTo() As System.Runtime.CompilerServices.YieldAwaitable Member of System.Threading.ThreadPoolEx Summary: Creates an awaitable that asynchronously yields to the ThreadPool when awaited.
关于.net - 我在哪里可以找到 ThreadPool.SwitchTo 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4815261/