Async DALINQ

I’ve been working on an Oxygene/WPF/DA application for roughly a year now. It uses DALINQ exclusively, and there are parts where the UI is getting bogged down by the DALINQ calls, so i think its time to learn now to use DA/DALINQ asynchronously to improve on this for users. Do you have any sample code i could look at to see what all is involved in converting my non-async code/calls to async calls?

Thanks

Alan

PS: I’m using the latest betas of both Elements and DA/ROSDK, in VS 2019 on Windows 10

Hello

Yes, DA LINQ has support for async data read and data update calls.
At first make sure that you have the RemObjects.DataAbstract.Async assembly referenced along with other Data Abstract assemblies. Also double-check that using section of the code file references RemObjects.DataAbstract.Linq

Then take a look at this sample code that reads some data and updates it:

    var adapter = this.fDataModule.DataAdapter;
	var query = from x in adapter.GetTable<Customers>() select x;
	var data = query.ToList();

	var entry = data[0];
	entry.Remarks = Guid.NewGuid().ToString();
	adapter.ApplyChanges();

This is synchronous code that can pause the main UI thread. This is how this code would look like in async style:

var adapter = this.fDataModule.DataAdapter;

var query = from x in adapter.GetTable<Customers>() select x;
var data = await adapter.LoadListAsync(query);

var entry = data[0];
entry.Remarks = Guid.NewGuid().ToString();
await adapter.ApplyChangesAsync();

As you can see not that much changes are required to make the data requests async.

Regards

2 Likes

Thanks Anton! Much appreciated!