我正在为WPF文本块分配一个大字符串,我想让它异步发生,甚至“流式”进入新位置。我很好奇我是否可以扩展字符串类以获得GetAwaiter(),任何想法?这不需要花哨,但我不喜欢它在分配大字符串时锁定的方式。
private async void listBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (ready && listOfData.Count > 0 && listBox.SelectedIndex >= 0) // this prevents issues when called by reloading (which counts as selection change)
{
var idx = listBox.SelectedIndex;
ResultBlock.Text = listOfData[idx]; // *** THIS IS WHAT I WANT TO HAPPEN ASYNC/PARALLEL/ETC
}
}