Message 1 of 7
Modeless WPF Behavior understanding with await & async
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello dears,
I'm Creating a Revit Add-in, In the code Below I'm trying to download some files from the Internet using await & async to hold my code till downloading files is complete then continue the code-(I replaced my code with await Task.Delay(5000); for simplification) , the problem is as follow:
- The Code is not waiting for the download to finish and it directly gives the user "Download Finished2" messege.
- The Code Not Running "Download Finished1" even if the method I call implemented successfully and I'm pretty sure that all files downloaded correctly.
- IF I replaced my method with Thread.Sleep(5000); all the code run very well without any issue.
private async Task Btn_Click()
{
TaskDialog.Show("RES", "Download Will Start now");
if (IU.CheckConnection())
{
await revitTask.Run(async (uiapp) =>
{
#Thread.Sleep(5000);
await Task.Delay(5000);
TaskDialog.Show("RES", "Download Finished1");
});
}
TaskDialog.Show("RES", "Download Finished2");
}