标签未在wpf中更新

时间:2015-09-24 06:40:49

标签: c# wpf multithreading dispatcher

我在WPF中遇到问题,当方法正在进行时标签不会更新。 这是代码。

private async void BtnMatching_Click_1(object sender, RoutedEventArgs e)
{
    var selectedItem = (dynamic)ListViewQueries.SelectedItems[0];

    var myQuery = _queryFolder[selectedItem] as Microsoft.TeamFoundation.WorkItemTracking.Client.QueryDefinition;

    DataTable dtRevision= new DataTable();
    DataTable dtExportData = new DataTable();

    var TTSList = Task<List<UsersModel>>.Factory.StartNew(() => TTSProcessing(TTSFileName));

    LblMessage.Content = "Processing TTS File...";
  //  LblMessage.Dispatcher.BeginInvoke(new ThreadStart(() => LblMessage.Content = "Processing TTS File..."));

        await TTSList;

    if (TTSList.Status == TaskStatus.RanToCompletion)
    {
     LblMessage.Dispatcher.BeginInvoke((Action)(() => LblMessage.Content = "File Completed, Now Executing Query...")); //--> This code is not working here
    }

//Other code
}

我想在TTSList任务完成时更新LblMessage标签。记住(其他代码意味着在IF块之后还有许多其他代码)。 感谢。

0 个答案:

没有答案