End of QueuedTask

654
2
Jump to solution
01-03-2018 12:17 PM
BrianBulla
Occasional Contributor III

In my code I am running some code in a QueuedTask.  After the QueuedTask code, I have some more code that seems to be getting run similtaneously to the QueuedTask, which is causing problems.

How do I stop the code from progressing until the QueuedTask is complete??

QueuedTask.Run(() =>
{

   //some code

}
); //end of QueuedTask

//more code down here, that seems to run while things are still processing in the QueuedTask

foreach()

{

   //included here is code that modifies a Windows Form that cannot run inside the QueuedTask, but needs to wait for the    QueuedTask to complete before running

}

etc.

Thanks!

0 Kudos
1 Solution

Accepted Solutions
SteveVan_Esch
Esri Contributor

You can use the await operator

    private async Task Foo()
    {
.
.
.
      await QueuedTask.Run(() =>
.
.
.

View solution in original post

0 Kudos
2 Replies
SteveVan_Esch
Esri Contributor

You can use the await operator

    private async Task Foo()
    {
.
.
.
      await QueuedTask.Run(() =>
.
.
.
0 Kudos
BrianBulla
Occasional Contributor III

Thanks Steve.  Here is what I finally did to get things working:

async private void ReloadFields()
        {
            await QueuedTask.Run(() =>
                {
                    //code here
                }
                );  //end of QueuedTask


                //More code here
                
        }
0 Kudos