home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / listpm4.zip / source / appmain.cpp next >
C/C++ Source or Header  |  1998-04-22  |  2KB  |  62 lines

  1. /*
  2.     listPM list files under Presentation Manager. Uses Open Class Libarary.
  3.     Copyright (C) 1998  Paul Elliott
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.     Paul Elliott
  20.     11900 Metric Blvd #J-181
  21.     Austin Tx 78758-3117
  22.     pelliott@io.com
  23.  
  24. */
  25. #include "appmain.hpp"
  26.  
  27.  
  28. /*
  29.  * Universal main routine.
  30.  * solves the following problem:
  31.  * when a processes' main threads ends it kill all sub threads
  32.  * reguardless of weather they have more work to do.
  33.  * This main routine solves this by waiting for all threads be for exiting.
  34.  * it starts a main thread specified by user, then waits for all threads.
  35.  * also it loads the argc and argv arguements into current application
  36.  * before starting a thread that must be defined by user which will
  37.  * do program main work.
  38.  * program must  define  MainThreadFn::run()
  39.  * which is code to do the work of the program.
  40.  *
  41.  */
  42. int main ( int argc, char * argv [] )
  43. {
  44.  
  45.    // set arguments into the application.
  46.    IApplication::current().setArgs( argc, argv );
  47.  
  48.    // processing for main thread here.
  49.  
  50.    // create and start main thread
  51.    IThread main_thread (  new MainThreadFn );
  52.    // new NainThreadFn will be stored into managed pointer
  53.    // so it will be deleted when this thread exits.
  54.  
  55.  
  56.    // if we have started threads, we must wait for them
  57.    // because otherwise the will be killed when main thread exits.
  58.    IThread::current().waitForAllThreads();
  59.  
  60.    return 0;
  61. };
  62.