SOL9 2.0 Sample: StopWatch

SOL9 2.0 Samples

1 Screenshot


2 Source code

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



#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)
{
    const TCHAR* appClass = _T("StopWatch");
    try {
      Application applet(appClass, 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 (...) {

    }

}

Last modified: 11 Nov 2009

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