How to run intensive code in background RRS feed

  • Question

  • I run a resource intensive, time consuming operation in my app. Whenever I do, the app's UI freezes until the operation has been completed. I was hoping I could do the operation using an asynchronous task, with the hopes of deprioritizing the task, so that the app's UI would be responsive while the work was being done. I normally do small asynchronous tasks as shown below:

            public async void CopyAllRecordsAndResetAddressAndSettingsCollectionsAsync(string SourceDBPath, bool DeleteRecordsInTargetTablesBeforeStarting)
                await ExecuteCopyAllRecordsAndResetAddressAndSettingsCollectionsAsync(SourceDBPath, DeleteRecordsInTargetTablesBeforeStarting);
            private async Task ExecuteCopyAllRecordsAndResetAddressAndSettingsCollectionsAsync(string SourceDBPath, bool DeleteRecordsInTargetTablesBeforeStarting)
                CopyAllRecords(SourceDBPath, DeleteRecordsInTargetTablesBeforeStarting);
                await Task.Delay(0);

    Based on what I've read, there is no way of deprioritizing a Task as used above. Can someone suggest a solution that would allow me to do my intensive operation, while keeping the UI of my app responsive? Thank you.

    • Edited by PDoug Sunday, November 30, 2014 10:52 PM
    Sunday, November 30, 2014 10:51 PM