void StartFetchOperation(object state) { ThreadPool.QueueUserWorkItem(s => { /* the command is in the state. the resultset is the local listcontent */ var parms = state as FetchOperationState; try { using (DbDataAdapter ad = db.NewDataAdapter()) { ad.SelectCommand = parms.cmdX; if (parms.timeout_seconds > 0) { ad.SelectCommand.CommandTimeout = parms.timeout_seconds; } var dt = new DataTable(parms.Name, parms.Namespace); ad.Fill(dt); /* deliver */ parms.dt = dt; } /* done */ this.FetchOperationCompleted(this, new AsyncCompletedEventArgs(error: null, cancelled: false, userState: state)); } catch (Exception nex) { /* added [dlatikay 20170921] */ if (parms != null && parms.cmdX != null) { try { /* [mpollhei>dlatikay 20180123] */ parms.cmdX.Cancel(); } catch (ObjectDisposedException) { } } /* likely canceled (timed out), so we should abort as well */ Tracing.ErrorDAL("Asynchronous fetch yielded with: {0}", nex.ToString()); this.FetchOperationCompleted(this, new AsyncCompletedEventArgs(error: nex, cancelled: true, userState: state)); } }, state); }