Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
bonami is currently offline  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()?
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Time callbacks when ticks overlap
Next Topic: Callbacks with 'Disable' feature
Goto Forum:
  


Current Time: Fri Jul 04 19:20:51 CEST 2025

Total time taken to generate the page: 0.03766 seconds