I am learning the new Async CTP and looking 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 can I find ThreadPool.SwitchTo? The SwithcTo method does not belong to the ThreadPool class.
I have a link to AsyncCtpLibrary.dll ... but not luck
For reference, CharlesO answered his question in the comments above:
OK, guys found this. Summary: Provides methods for interacting with ThreadPool. Remarks: ThreadPoolEx is a placeholder.Sharing Function SwitchTo () As System.Runtime.CompilerServices.YieldAwaitable Member System.Threading.ThreadPoolEx Summary: Creates asynchronously gives ThreadPool when waiting.
OK, guys found this. Summary: Provides methods for interacting with ThreadPool. Remarks: ThreadPoolEx is a placeholder.
Sharing Function SwitchTo () As System.Runtime.CompilerServices.YieldAwaitable Member System.Threading.ThreadPoolEx Summary: Creates asynchronously gives ThreadPool when waiting.
ThreadPool.SwitchTo , anit-. , , , . finally , await finally.
ThreadPool.SwitchTo
finally
await
public async void button1_Click(object sender, EventArgs e) { await ThreadPool.SwitchTo(); try { // Do something dangerous here. } finally { await button1.Dispatcher.SwitchTo(); // COMPILE ERROR! } }
, , . , Task.Run 1 await.
Task.Run
Source: https://habr.com/ru/post/1788153/More articles:Anonymization using the 2 axis - javausing onBackPressed () with backward compatibility - androidmysql выбирает любое одно из двух полей по отношению к значению третьего поля - mysqlUsing jQuery and JSON to use Asp.net server-side asynchronous web methods - jsonRecursive iteration in C # - c #Как рассчитать средние значения с помощью функции Ruby Inject - rubyWhy doesn't git gui follow the comment lines added by the git hook? - gitChoosing Java Methods? - javaWhat is the meaning of the journal to use for the implementation of divergence Kullback leibler? - javaEF4 CTP5 - HasColumnType not working - entity-framework-4All Articles