Home » U++ Library support » U++ Callbacks and Timers » how to use timer id? and how to kill a timer
Re: how to use timer id? [message #27525 is a reply to message #27501] |
Thu, 22 July 2010 04:09   |
 |
bonami
Messages: 186 Registered: June 2007 Location: Beijing
|
Experienced Member |
|
|
my problem is not how to envoke the TopWindow's functions in the Thread, but how to separate these threads. I traced your code. TimerCB(-1000) is not thread safe, it calls CreateCounter() synchronously. Since the timer is executed in TopWindow thread, this is not what I want. In fact, timer creation is not a problem. Killing it is.
Here's a demo of my code,
class e : public TopWindow {
class a {
Thread t;
void f(void);
};
void cb(void);
a aa;
};
void e::a::f(void)
{
Sleep(1000);
SetTimeCallback(1000, cb, 10);
Sleep(1000);
KillTimeCallback(10);
}
void e::cb(void)
{
}
GUI_APP_MAIN
{
e ee;
ee.aa.t.Run(callback(&ee.aa, &e::a::f));
ee.Run();
}
This code cannot build. it just shows my intention. in the Thread function f, I create a timer expiring after 1 second. Then it sleeps 1 second and kills the timer. The problem is, I do not know whether the timer is already envoked when I kill it. That is why I want to put all the timer operations in TopWindow thread and I think that is what should be done. So I need to send a message to TopWindow and let it create or kill the timer, from an MS view.
Plus, why did you test Thread::IsShutdownThreads()?
|
|
|
 |
|
how to use timer id? and how to kill a timer
By: bonami on Tue, 20 July 2010 10:03
|
 |
|
Re: how to use timer id?
By: mrjt on Wed, 21 July 2010 10:46
|
 |
|
Re: how to use timer id?
By: bonami on Wed, 21 July 2010 11:28
|
 |
|
Re: how to use timer id?
By: mrjt on Wed, 21 July 2010 12:54
|
 |
|
Re: how to use timer id?
By: bonami on Thu, 22 July 2010 04:09
|
 |
|
Re: how to use timer id?
By: mrjt on Thu, 22 July 2010 10:58
|
 |
|
Re: how to use timer id?
By: bonami on Thu, 22 July 2010 11:32
|
 |
|
Re: how to use timer id?
By: mrjt on Thu, 22 July 2010 12:10
|
 |
|
Re: how to use timer id?
By: bonami on Fri, 23 July 2010 04:28
|
 |
|
Re: how to use timer id?
By: mrjt on Fri, 23 July 2010 11:32
|
 |
|
Re: how to use timer id?
By: bonami on Mon, 26 July 2010 04:16
|
Goto Forum:
Current Time: Fri Jul 04 19:20:51 CEST 2025
Total time taken to generate the page: 0.03766 seconds
|