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!
Solved! Go to Solution.
You can use the await operator
You can use the await operator
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
}