예제 #1
0
        private static void NewTask()
        {
            lock (saved)
            {
                if (i >= matrix.M)
                {
                    return;
                }
                Console.WriteLine("Start [{0}, {1}] ", i, j);
                //int value = i * 100 + j;
                //Process process = new Process();

                //process.StartInfo.FileName = Process.GetCurrentProcess().MainModule.ModuleName;
                //process.StartInfo.Arguments = Convert.ToString(value);
                //process.StartInfo.CreateNoWindow = true;
                //process.StartInfo.UseShellExecute = false;

                //process.EnableRaisingEvents = true;
                //process.Exited += ProcessOnExited;

                //saved[i, j] = process;
                //saved[i, j].Start();

                ProcessWrap pr = new ProcessWrap(i, j);
                pr.Start();

                j++;
                if (j == matrix.N)
                {
                    i++;
                    j = 0;
                }
            }
        }
예제 #2
0
        //private static void ProcessOnExited(object sender, EventArgs e)
        private static void ProcessOnExited(int ret, ProcessWrap pr)
        {
            finishedProcess++;
            Console.WriteLine("Process {0} finised!", finishedProcess);
            try
            {
                matrix.minor[pr.I, pr.J] = ret;
            }
            finally
            {
                pr.End();
            }
            if (finishedProcess == problemSize)
            {
                //for (var i = 0; i < matrix.N; i++)
                //{
                //    for (var j = 0; j < matrix.N; j++)
                //    {
                //        try
                //        {
                //            int ret = saved[i, j].ExitCode;
                //            matrix.minor[i, j] = ret;
                //        }
                //        finally
                //        {
                //            saved[i, j].Dispose();
                //        }
                //    }
                //}

                InvertMatrix();
            }
            else
            {
                NewTask();
            }
        }