ThinkGeo.com    |     Documentation    |     Premium Support

Understanding of new RefreshAsync()

Hi, quick question, we have updated our application to the newest Version and with that our previous Refresh() calls on our overlays became RefreshAsync().
We have not added any awaits and the map works great. I am wondering if we are doing something wrong? Should every RefreshAsync() call be awaited? What is the benefit of doing so?

Thanks!

Hi Julian,

The main issue is that RefreshAsync() might not complete before the next line of code runs. For example:

map.RefreshAsync();
DoSomthing();

If DoSomething() relies on the map being fully updated—such as reading properties or making further updates—you could run into inconsistencies because RefreshAsync() is still in progress.

Calling an async method without await means you’re “fire-and-forget”: you have no control over when it finishes, and you can’t catch any exceptions it might throw. This can lead to hard-to-debug issues. For these reasons, we always recommend await async methods.

Thanks,
Ben