Search code examples
.netasynchronousthreadpoolasync-ctp

Where can i find the ThreadPool.SwitchTo method?


I am studying the new Async CTP and going through some sample code,

I came across this piece of code:

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; 
}

Please where do I find ThreadPool.SwitchTo? SwithcTo method is not on the ThreadPool class

i have a referece to AsyncCtpLibrary.dll ... but no luck


Solution

  • For reference, CharlesO answered his question within the comments above:

    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.