I have problems with understanding how async fill works.
I use BeginFill, SuspendFill & EndFill methods expected what they work as follow:
BeginFill(AsyncCallbackEndFill, null) - begins to fill table asynchronously.
When SuspendFill() is invoked - dataTable stops to fill and AsyncCallbackEndFill is called.
EndFill() - fetchs all selected results to DataTable.
But there is one subtle notion:
When current fill operation was interrupted by SuspendFill() and then BeginFill is invoked next time - preeceeded fill query continue to execute on server. Consider example:
Suppose datatable has 1000 rows.
Code: Select all
IAsyncResult res = this.dataSet1.CLIENT.BeginFill(null,null);
System.Threading.Thread.Sleep(5000);
this.dataSet1.CLIENT.SuspendFill(true);
this.dataSet1.CLIENT.EndFill(res);
Diagnostics.Debug.WriteLine(this.dataSet1.CLIENT.Rows.Count);
this.dataSet1.CLIENT.Clear();
//this.dataSet1.CLIENT.SelectCommand.CommandText = " CLASSIFIED IS NULL "
res = this.dataSet1.CLIENT.BeginFill(null, null);
res.AsyncWaitHandle.WaitOne();
Diagnostics.Debug.WriteLine(this.dataSet1.CLIENT.Rows.Count);
Result :
200
800
How i can change this behaviour. And cancel Fill operation at all?
[/code]