/// <summary> /// Prepare updates asynchronously /// </summary> /// <param name="callback">Callback function to call when done; can be null</param> /// <param name="state">Allows the caller to preserve state; can be null</param> public IAsyncResult BeginPrepareUpdates(AsyncCallback callback, Object state) { // Create IAsyncResult object identifying the // asynchronous operation var ar = new UpdateProcessAsyncResult(callback, state); // Use a thread pool thread to perform the operation ThreadPool.QueueUserWorkItem(o => { try { // Perform the operation; if sucessful set the result PrepareUpdates(); ar.SetAsCompleted(null, false); } catch (Exception e) { // If operation fails, set the exception ar.SetAsCompleted(e, false); } }, ar); return(ar); // Return the IAsyncResult to the caller }
/// <summary> /// Prepare updates asynchronously /// </summary> /// <param name="callback">Callback function to call when done; can be null</param> /// <param name="state">Allows the caller to preserve state; can be null</param> public IAsyncResult BeginPrepareUpdates(AsyncCallback callback, Object state) { // Create IAsyncResult object identifying the // asynchronous operation var ar = new UpdateProcessAsyncResult(callback, state); // Use a thread pool thread to perform the operation ThreadPool.QueueUserWorkItem(o => { try { // Perform the operation; if sucessful set the result PrepareUpdates(); ar.SetAsCompleted(null, false); } catch (Exception e) { // If operation fails, set the exception ar.SetAsCompleted(e, false); } }, ar); return ar; // Return the IAsyncResult to the caller }