Пример #1
0
        private void ToFileAsyncCB(IAsyncResult ar)
        {
            ToFileAsyncDelegate dlgt = (ToFileAsyncDelegate)ar.AsyncState;

            // Call EndInvoke, since the docs say we MUST
            dlgt.EndInvoke(ar);

            // Inform caller that the asynchronous operation is now complete
            if (this.NotifyDoneCallback != null)
            {
                this.NotifyDoneCallback(this, null);
            }
        }
Пример #2
0
        /// <summary>
        /// Call to asynchronously convert data to SPSS format using a passed in SQL query
        /// to provide the data.
        /// </summary>
        /// <param name="dataTable">
        /// The DataTable to convert to SPSS format
        /// </param>
        /// <param name="data">An enumerable list of DataRows.</param>
        /// <param name="spssSavFilename">
        /// The fully-qualified target .SAV file to save results to
        /// </param>
        /// <param name="fillInMetaDataCallback">
        /// Callback function to provide per-variable metadata
        /// </param>
        /// <param name="notifyDoneCallback">
        /// The method to call when the process is complete.
        /// </param>
        /// <returns>
        /// Returns a handle to poll the status of the conversion.
        /// </returns>
        public static IAsyncResult ToFileAsync(DataTable dataTable, IEnumerable <DataRow> data, string spssSavFilename,
                                               Action <SpssVariable> fillInMetaDataCallback, EventHandler notifyDoneCallback)
        {
            // Spin off an asynchronous thread to do the work
            // Be sure to use a callback function, even if we don't care when this
            // conversion is done, since we must call EndInvoke.
            ToFileAsyncDelegate dlgt = new ToFileAsyncDelegate(ToFile);

            // Instantiate an instance of this class, to save the vbNotifyDone parameter
            // so that we know who to tell when this operation is complete.
            SpssConvert instance = new SpssConvert(notifyDoneCallback);

            return(dlgt.BeginInvoke(dataTable, data, spssSavFilename, fillInMetaDataCallback,
                                    new AsyncCallback(instance.ToFileAsyncCB), dlgt));
        }
Пример #3
0
        /// <summary>
        /// Call to asynchronously convert data to SPSS format using a passed in SQL query 
        /// to provide the data.
        /// </summary>
        /// <param name="dataTable">
        /// The DataTable to convert to SPSS format
        /// </param>
        /// <param name="data">An enumerable list of DataRows.</param>
        /// <param name="spssSavFilename">
        /// The fully-qualified target .SAV file to save results to
        /// </param>
        /// <param name="fillInMetaDataCallback">
        /// Callback function to provide per-variable metadata
        /// </param>
        /// <param name="notifyDoneCallback">
        /// The method to call when the process is complete.
        /// </param>
        ///	<returns>
        ///	Returns a handle to poll the status of the conversion.
        ///	</returns>
        public static IAsyncResult ToFileAsync(DataTable dataTable, IEnumerable<DataRow> data, string spssSavFilename,
            Action<SpssVariable> fillInMetaDataCallback, EventHandler notifyDoneCallback)
        {
            // Spin off an asynchronous thread to do the work 
            // Be sure to use a callback function, even if we don't care when this 
            // conversion is done, since we must call EndInvoke.
            ToFileAsyncDelegate dlgt = new ToFileAsyncDelegate(ToFile);

            // Instantiate an instance of this class, to save the vbNotifyDone parameter
            // so that we know who to tell when this operation is complete.
            SpssConvert instance = new SpssConvert(notifyDoneCallback);
            return dlgt.BeginInvoke(dataTable, data, spssSavFilename, fillInMetaDataCallback,
                new AsyncCallback(instance.ToFileAsyncCB), dlgt);
        }