Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
R

RCM

@RCM
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Resource Access in Multiple Timers in Single thread
    R RCM

    Thanks for your reply. I would like to know if critical sections can be used to lock a section of code within the same thread. Critical Sections within same thread - possible ? Cheers Raja

    C / C++ / MFC c++ performance help question announcement

  • Resource Access in Multiple Timers in Single thread
    R RCM

    Hi, I have a dialog based MFC application which has 2 timers with same interval (say 5 mins) accessing a single resource. A structure instance which is a member variable of the App class is being updated in one timer and the same structure instance is being used in another timer. ( Typically, the memory resource is being accessed for write in one timer callback and for read in another timer callback ). The code snippet something is like this, CMyFrameDlg::TimerCallback1(...) { ... theApp.m_Struct.nVar1 = 10; theApp.m_Struct.szVar2 = "test"; ... ... } CMyFrameDlg::TimerCallback2(...) { ... ... localnVar = theApp.m_Struct.nVar1; localszVar = theApp.m_Struct.szVar2; ... } The 2 timers get called simultaneously. Issue is, that the values dont get reflected properly in timer2 and while the struct is being accessed in timer2 it is being updated simulataneously in timer1. Both timers belong to the same Thread. 1.) I need to update the same resource in one timer and use it for some other purpose in the second timer. Is it possible ? 2.) I also have certain WM_.. messages posted from another thread to this thread on which a callback gets invoked. And this callback also accesses the same structure instance, but the values are not properly updated. Why is it so ? Point is.. accessing the same resource ( memory) in multiple timers of the same thread. And also accessing same resource in multiple callbacks of the same thread (like user defined WM_message callbacks). Is there any restriction or way to do that ? Anxiously Waiting for a reply :~ Cheers Raja

    C / C++ / MFC c++ performance help question announcement
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups