Is there any possibility to cancel 'FetchAsync' operation?

Is there any possibility to cancel 'FetchAsync' operation?

Old forum URL: forums.lhotka.net/forums/t/12278.aspx


sash_kr posted on Sunday, December 22, 2013

I'm converting my existence project to CSLA.NET .

Now, I'm working on 'live search' feature (like when you type letters in google search textbox and it suggests you results). My project based on ADO.NET, so I'm just using something like this:

async Task<DataTable> SearchText(string text, CancellationTokenSource cancelToken)
{
    ...
    var asyncRes = cmd.BeginExecuteReader();
    while (!asyncRes.IsCompleted)
    {
        if (cancelToken.IsCancellationRequested)
            cmd.Cancel();
        Thread.Sleep(5);
    }
    using (var dr = cmd.EndExecuteReader(asyncRes))
        ...
}

Every time when TextBox.TextChanged event raised I'm canceling current "SearchText" operation and execute new one  "SearchText" operation.

Can I do something similar in CSLA.NET?

I know, I can just ignore "FetchAsync" result but I think it would be inefficient.

 

Copyright (c) Marimer LLC