示例#1
0
        private static void MatMulCalculator_Completed(
            object sender,
            MatMulCompletedEventArgs e)
        {
            Guid taskId = (Guid)e.UserState;

            if (e.Cancelled)
            {
                Console.WriteLine("Operation Canceled");
            }
            else if (e.Error != null)
            {
                Console.WriteLine("Error");
            }
            else
            {
                double[,] result = e.Result;

                for (int i = 0; i < result.GetLength(0); i++)
                {
                    for (int k = 0; k < result.GetLength(1); k++)
                    {
                        Console.Write(result[i, k] + " ");
                    }

                    Console.WriteLine();
                }
            }

            Handle.Set();
        }
        private void Completion(double[,] mat1, double[,] mat2, double[,] result,
                                Exception ex, bool canceled, AsyncOperation ao)
        {
            if (!canceled)
            {
                lock (HybridDictionary.SyncRoot)
                {
                    HybridDictionary.Remove(ao.UserSuppliedState);
                }
            }

            MatMulCompletedEventArgs e =
                new MatMulCompletedEventArgs(
                    mat1,
                    mat2,
                    result,
                    ex,
                    canceled,
                    ao.UserSuppliedState);


            ao.PostOperationCompleted(OnCompletedCallback, e);
        }
        public void CalculateCompleted(object operationState)
        {
            MatMulCompletedEventArgs e = operationState as MatMulCompletedEventArgs;

            matMulCompleted?.Invoke(this, e);
        }