我正在研究新的Async CTP並通過一些示例代碼,我在哪裏可以找到ThreadPool.SwitchTo方法?
我遇到了這段代碼:
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 ...但沒有運氣
它看起來像我的擴展方法。 –
假設您已經在Visual Studio中加載了代碼,請右鍵單擊該方法的名稱並選擇「轉到定義」。它會立即將您帶到定義該方法的位置,以便您可以研究它。我懷疑chibacity的假設是它是一個在'ThreadPool'類中定義的擴展方法是正確的。 –
所以我雖然,但從哪裏?我添加了對AsyncCtpLibrary.dll的引用,但沒有運氣 –