/*
* 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 (...) {
}
}
|