static void Done(IAsyncResult cookie)
    {
        WorkInvoker method = (WorkInvoker)cookie.AsyncState; //info about asynch operation
        int         result = method.EndInvoke(cookie);

        Console.WriteLine("String II length is: " + result);
    }
Exemple #2
0
        private void EndWork(IAsyncResult result)
        {
            AsyncResult asyncResult   = (AsyncResult)result;
            WorkInvoker asyncDelegate = (WorkInvoker)asyncResult.AsyncDelegate;

            try
            {
                asyncDelegate.EndInvoke(result);
                OnFinish(EventArgs.Empty);
            }
            catch (Exception e)
            {
                // Marshal exceptions back to the UI
                OnError(new ErrorEventArgs(e));
            }
//            catch
//            {
//                // Do our exception handling; include a default catch
//                // block because this is the final handler on the stack for this
//                // thread, and we need to log these kinds of problems
//                OnError( new ErrorEventArgs( null ) );
//            }
        }