예제 #1
0
        public void CalculateCompleted(object state)
        {
            MatMulCompletedEventArgs e = state as MatMulCompletedEventArgs;

            if (MatMulCompleted != null)
            {
                MatMulCompleted(this, e);
            }

            if (e.Cancelled)
            {
                Console.WriteLine("Thread {0} reports with partial result:", e.UserState);
            }
            else
            {
                Console.WriteLine("Thread {0} reports with result:", e.UserState);
            }

            for (int i = 0; i < e.Size; i++)
            {
                for (int j = 0; j < e.Size; j++)
                {
                    //fancy printing techniques
                    if (j == e.Size - 1)
                    {
                        Console.WriteLine(e.Mat[i, j]);
                    }
                    else
                    {
                        Console.Write(e.Mat[i, j] + "\t");
                    }
                }
            }
        }
예제 #2
0
        void Completion(int size, double[,] mat, Exception ex, bool cancelled, AsyncOperation ao)
        {
            if (!cancelled)
            {
                lock (userStateToLifetime.SyncRoot)
                {
                    userStateToLifetime.Remove(ao.UserSuppliedState);
                }
            }
            //pakujemy rezultat operacji - chodzi nam o macierz wynikowa mat
            MatMulCompletedEventArgs e = new MatMulCompletedEventArgs(mat, size, ex, cancelled, ao.UserSuppliedState);

            ao.PostOperationCompleted(onCompletedCallback, e);
        }