Пример #1
0
        public void DoTables(Program p)
        {
            Helper h = new Helper();

            List <TableGeneratorParameters> list = new List <TableGeneratorParameters>();

            h.MessageVerbose("### Generating code gen tables ###");

            List <string> tables = p._di.Tables.Get();

            if (tables.Count >= 1)                                                                  // anything to do ?
            {
                using (MyThreadPoolManager tpm = new MyThreadPoolManager(p._threads, tables.Count)) // max threads: _threads, queue length: no of tables
                {
                    foreach (string table in tables)
                    {
                        TableGeneratorParameters tgp = new TableGeneratorParameters();
                        list.Add(tgp);

                        tgp.p       = p;
                        tgp.fqtable = table;

                        tpm.Queue(new TableGeneratorThreadPoolItem(tgp));
                    }
                    tpm.WaitUntilAllStarted();
                    tpm.WaitUntilAllFinished();
                }
            }

            h.MessageVerbose("### Generating code gen tables - done ###");

            // handle any thread exceptions
            foreach (TableGeneratorParameters tgp in list)
            {
                if (tgp.exception != null)
                {
                    throw new ApplicationException("DoTables() worker thread exception", tgp.exception);
                }
            }
        } // end do tables
Пример #2
0
        //--------------------------------------------------------------------------------------------------------------------

        public TableGeneratorThreadPoolItem(TableGeneratorParameters tgp)
        {
            _tgp = tgp;
        }