I am creating a background thread in a windows form application to do some process that takes time while handling huge data. However, I still want some other methods or processes to wait until this thread finishes its work.
To create a background thread, I used below inline code.
Task.Factory.StartNew(() => GenerateXml2Resx(account, features, codes, outputDir));
So once, this process of generating all *.resx files from xml data is done, I want my application to proceed further.
Thanks.
You need to call the other methods in a
Task.ContinueWith()callback, which will only run after the first task finishes.If you want that to run in the UI thread, pass
TaskScheduler.FromCurrentSynchronizationContext().