DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Communication between threads......

Hybrid View

  1. #1
    Rashid Guest

    Communication between threads......


    Hi !
    I am just an ameteur programmer of VC, and know the basics of it till
    yet. I am working on a project which is dialog based and the main job is
    done in the worker thread while the main thread handles messages and updates
    dialog controls. General program layout is this.
    .................................................
    In Dialog class:(CProgramDlg)
    {
    AfxBeginThread(ThreadFunc........)
    }

    In ThreadFunc function:
    {
    CHandleDisplay HD; // this is the main working object
    HD.ShowDisplay(...); // All job is done in here.

    return;
    }
    ...................................................
    I am facing two problems now....
    1: I have to Update dialog controls from HD obj. MFC don't let
    me do it as it is illegal to access member variable of
    CProgramDlg( obj of one thread) from obj of another thread.
    ( I thought on using trasit global variables which will take
    data in HD.ShowDisplay(),in here a a user-defined message
    is posted to Dlg class, then user-define message handler
    in CProgramDlg updates the dialog controls from global
    variables....
    Cann't this be done without globalization....
    )

    2: I need 3 timers in CHandleDisplay class. I can get one by
    catching WM_TIMER message for this class. What about the
    other timing routines. (precise timing is required i.e 20ms)

    Thanx in advance,
    Rashid.
    SeaBird505@hotmail.com



  2. #2
    eric janssen Guest

    Re: Communication between threads......



    don't use the SetTimer api if you want to do precise timing. instead create
    a seperate thread and use the QueryPerformanceCounter api funtion.


    "Rashid " <SeaBird505@hotmail.com> wrote:
    >
    >Hi !
    > I am just an ameteur programmer of VC, and know the basics of it till
    >yet. I am working on a project which is dialog based and the main job is
    >done in the worker thread while the main thread handles messages and updates
    >dialog controls. General program layout is this.
    >.................................................
    >In Dialog class:(CProgramDlg)
    >{
    > AfxBeginThread(ThreadFunc........)
    >}
    >
    >In ThreadFunc function:
    >{
    > CHandleDisplay HD; // this is the main working object
    > HD.ShowDisplay(...); // All job is done in here.
    >
    > return;
    >}
    >...................................................
    >I am facing two problems now....
    > 1: I have to Update dialog controls from HD obj. MFC don't let
    > me do it as it is illegal to access member variable of
    > CProgramDlg( obj of one thread) from obj of another thread.
    > ( I thought on using trasit global variables which will take
    > data in HD.ShowDisplay(),in here a a user-defined message
    > is posted to Dlg class, then user-define message handler
    > in CProgramDlg updates the dialog controls from global
    > variables....
    > Cann't this be done without globalization....
    > )
    >
    > 2: I need 3 timers in CHandleDisplay class. I can get one by
    > catching WM_TIMER message for this class. What about the
    > other timing routines. (precise timing is required i.e 20ms)
    >
    >Thanx in advance,
    >Rashid.
    >SeaBird505@hotmail.com
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center