mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
reference: Ctrl::Lock example
git-svn-id: svn://ultimatepp.org/upp/trunk@1191 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
142bdd60c3
commit
0724f87d20
3 changed files with 62 additions and 0 deletions
11
reference/GuiMT_Lock/GuiMT_Lock.upp
Normal file
11
reference/GuiMT_Lock/GuiMT_Lock.upp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
description "This package demonstrates the use of Ctrl::Lock in MT applications\377";
|
||||
|
||||
uses
|
||||
CtrlLib;
|
||||
|
||||
file
|
||||
main.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI MT";
|
||||
|
||||
4
reference/GuiMT_Lock/init
Normal file
4
reference/GuiMT_Lock/init
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef _GuiLock_icpp_init_stub
|
||||
#define _GuiLock_icpp_init_stub
|
||||
#include "CtrlLib/init"
|
||||
#endif
|
||||
47
reference/GuiMT_Lock/main.cpp
Normal file
47
reference/GuiMT_Lock/main.cpp
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
struct App : TopWindow {
|
||||
Thread work;
|
||||
|
||||
void Work();
|
||||
|
||||
ArrayCtrl list;
|
||||
|
||||
typedef App CLASSNAME;
|
||||
|
||||
App();
|
||||
~App();
|
||||
};
|
||||
|
||||
void App::Work()
|
||||
{
|
||||
int q = 0;
|
||||
while(!Thread::IsShutdownThreads()) {
|
||||
for(int i = 0; i < 100; i++) {
|
||||
Ctrl::Lock __(list);
|
||||
list.Set(i, 0, (int64)Random());
|
||||
}
|
||||
Sleep(10);
|
||||
}
|
||||
}
|
||||
|
||||
App::App()
|
||||
{
|
||||
list.AddColumn("Test");
|
||||
Add(list.SizePos());
|
||||
work.Run(THISBACK(Work));
|
||||
}
|
||||
|
||||
App::~App()
|
||||
{
|
||||
Thread::ShutdownThreads();
|
||||
work.Wait();
|
||||
}
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
App app;
|
||||
app.Run();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue