BUG? GenerateGeodatabaseAsync returns immediately

2444
4
Jump to solution
11-27-2014 12:47 AM
JuhoVainio
Occasional Contributor

I'm calling the GenerateGeodatabaseAsync method (with the await keyword) of GeodatabaseSyncTask and the method returns immediately. The method is marked as Async, so I'd expect it to wait until the task has been completed.

Can anyone confirm this behaviour or explain why it behaves differently from normal Async behaviour?

Sample:

public async Task<GenerateGeodatabaseResult>(Uri uri)
{
    var gdbTask = new GeodatabaseSyncTask(uri);

    // ...
     
    // this returns immediately (as if it was an async void method)
    return await gdbTask.GenerateGeodatabaseAsync(gdbParams, GdbCompleteCallback, new TimeSpan(0, 0, 5), progress, cancelToken);
}
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor

It's the normal behavior.

GenerateGeodatabaseAsync returns as soon as the the generation is executing on the server.

You have to use the callback to follow the progress and know when the task ends.

You can look at the GenerateGeodatabase sample or the SyncGeodatabase sample  which demonstrate the process..

View solution in original post

0 Kudos
4 Replies
DominiqueBroux
Esri Frequent Contributor

It's the normal behavior.

GenerateGeodatabaseAsync returns as soon as the the generation is executing on the server.

You have to use the callback to follow the progress and know when the task ends.

You can look at the GenerateGeodatabase sample or the SyncGeodatabase sample  which demonstrate the process..

0 Kudos
JuhoVainio
Occasional Contributor

I see. I was using another example from ESRI that didn't have the lines:

ReportStatus("Waiting on geodatabase from server...");
var statusResult = await tcs.Task;

Thanks for the fast reply.

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi,

Please can you post the link to the other sample? - I would like to see if we can fix up that code.

Cheers

Mike

0 Kudos
JuhoVainio
Occasional Contributor

It's the sample code on this page https://developers.arcgis.com/net/desktop/guide/create-an-offline-map.htm

The example code is on the button click event (async void) so the "immediate return" behaviour is not a concent here...

0 Kudos