SOL9 Sample: StopWatch

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * StopWatch.cpp 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


#define COMMONCONTROLS_V6

#include <sol\Application.h>
#include <sol\Thread.h>
#include <sol\Stdio.h>
//2009/10/08
#include <sol/AppEntry.h>

namespace SOL {

class StopWatch :public Thread {
private:
    int     seconds;
  
public:
    StopWatch(int interval) {
        seconds = interval;
    }

public:
  void run() {
  int n = 0;
  while (n < seconds) {
      
      sleep(1000); 
      // Do something here.
      Printf(_T("StopWatch %d\r\n"), n++);
        }
    }
};

}
//
void Main(int argc, TCHAR** argv)
{
  ModuleFileName module(argv[0]);
  const TCHAR* name = module.getFileName();
  try {
    Application applet(name, argc, argv);
  
    MessageBox(NULL, _T("Thread will start.\r\nAfter 10 seconds, a MessageBox will be shown.Please press [OK] button"),
      _T("StopWatch"), MB_ICONINFORMATION|MB_OK);

    StopWatch stopWatch(10);  // Create an instance of StopWatch
    stopWatch.start();        // Start the thread.
    stopWatch.wait();         // Wait the termination. 

    MessageBox(NULL, _T("Thread terminated."), 
      _T("StopWatch"), MB_ICONINFORMATION|MB_OK);

  } catch (Exception& ex) {
    caught(ex);
  } catch (...) {
    caught(UnknownException());
  }
}

Last modified: 1 Feb 2017

Copyright (c) 2017 Antillia.com ALL RIGHTS RESERVED.