Exemplo n.º 1
0
        /// <summary>
        /// This function will be called by SendOrPostCallback to raise Method1Completed Event
        /// </summary>
        /// <param name="operationState">Method1CompletedEventArgs object</param>

        private void CalculateCompleted(object operationState)
        {
            MathMulCompletedEventArgs e = operationState as MathMulCompletedEventArgs;

            if (MathMulCompleted != null)
            {
                MathMulCompleted(this, e);
            }
        }
Exemplo n.º 2
0
 private static void onMathMulCompleted(object sender, MathMulCompletedEventArgs e)
 {
     lock (thisLock)
     {
         Console.WriteLine("macierz wejsciowa 1:");
         show(e.mat1);
         Console.WriteLine("macierz wejsciowa 2:");
         show(e.mat2);
         Console.WriteLine("macierz wynikowa: ");
         show(e.mat_res);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// This method does the actual work
        /// </summary>
        /// <param name="message"></param>
        /// <param name="asyncOp"></param>
        private void MathMulWorker(double[][] mat1, double[][] mat2, AsyncOperation asyncOp)
        {
            double[][] mat_res = MatMultiply(mat1, mat2);

            lock (tasks.SyncRoot)
            {
                tasks.Remove(asyncOp.UserSuppliedState);
            }
            MathMulCompletedEventArgs e = new MathMulCompletedEventArgs(mat1, mat2, mat_res, null, false, asyncOp.UserSuppliedState);

            asyncOp.PostOperationCompleted(onCompletedDelegate, e);
        }
Exemplo n.º 4
0
        private void CompletionMethod(double[][] mat1, double[][] mat2, double[][] mat_res, Exception exception, bool canceled, AsyncOperation asyncOp)
        {
            // If the task was not previously canceled,
            // remove the task from the lifetime collection.
            if (!canceled)
            {
                lock (userStateToLifetime.SyncRoot)
                {
                    userStateToLifetime.Remove(asyncOp.UserSuppliedState);
                }
            }

            // Package the results of the operation in a
            // CalculatePrimeCompletedEventArgs.
            MathMulCompletedEventArgs e = new MathMulCompletedEventArgs(mat1, mat2, mat_res, exception, canceled, asyncOp.UserSuppliedState);

            // End the task. The asyncOp object is responsible
            // for marshaling the call.
            asyncOp.PostOperationCompleted(onCompletedDelegate, e);

            // Note that after the call to OperationCompleted,
            // asyncOp is no longer usable, and any attempt to use it
            // will cause an exception to be thrown.
        }