fed
fed

Reputation: 9

ContinueWith method doesn't run some code but other yes

I have a task object that downloads some stuff from the azure blob, in this case an exe. I want to trigger the end of the download to open the .exe automatically. I found that the ContinueWith method should work for me.

The problem is that if I do something like below (a simple msgbox) I see the code working well and the msgbox shown when the task is over.

Dim downloadTask As Task = Task.Run(Function() blobmnger.downloadWithProgress("QGIS-OSGeo4W-3.16.7-1-Setup-x86_64.exe", "startupResources", utils, up))

downloadTask.ContinueWith(Sub(task)
                              If task.Status = TaskStatus.RanToCompletion Then
                                  MessageBox.Show($"qgis has completed his download here {Path.Join(utils, "QGIS-OSGeo4W-3.16.7-1-Setup-x86_64.exe")} you can close the window ")
                              End If
                          End Sub)

If I change the code with the app doesn't break but doesn't do anything:

downloadTask.ContinueWith(Sub(task)                                             
                              If task.Status = TaskStatus.RanToCompletion Then
                                  up.close()
                                  process.Start(Path.Join(utils, "QGIS-OSGeo4W-3.16.7-1-Setup-x86_64.exe")) 
                              End If
                          End Sub)

In this case up is a form object that represents a progress bar that keeps track of the progress of the download.

Even if I wrap the Process.start in a try block it doesn't pop any exception.

Upvotes: 0

Views: 47

Answers (0)

Related Questions