Click here to Skip to main content
16,006,065 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralQuestion about CImageList.ExtractIcon(),thanks! Pin
Anonymous24-Nov-03 5:06
Anonymous24-Nov-03 5:06 
GeneralRe: Question about CImageList.ExtractIcon(),thanks! Pin
Roger Allen24-Nov-03 5:39
Roger Allen24-Nov-03 5:39 
GeneralRe: Question about CImageList.ExtractIcon(),thanks! Pin
YanBin24-Nov-03 6:04
YanBin24-Nov-03 6:04 
GeneralRe: Question about CImageList.ExtractIcon(),thanks! Pin
Roger Allen24-Nov-03 6:43
Roger Allen24-Nov-03 6:43 
GeneralRe: Question about CImageList.ExtractIcon(),thanks! Pin
David Crow24-Nov-03 5:50
David Crow24-Nov-03 5:50 
GeneralRe: Question about CImageList.ExtractIcon(),thanks! Pin
YanBin24-Nov-03 15:40
YanBin24-Nov-03 15:40 
GeneralRe: Question about CImageList.ExtractIcon(),thanks! Pin
David Crow25-Nov-03 2:43
David Crow25-Nov-03 2:43 
GeneralMulti-threading problem Pin
BHulme24-Nov-03 4:57
BHulme24-Nov-03 4:57 
I'm writing a multi-threaded serial port program, that requires the implementation of a highly precise timer routine (around 3ms accuracy). To do this I create a worker thread which sleeps for 3ms (this is actually based upon the code from an article on windows timers from this site), processes a small amount of data and then posts a message on the windows message queue using PostMessage. The problem is when I do this I get an Access Violation.

All my related variables are stored on the heap and the handle I'm using is definately valid. I do a similar thing in each of the serial reader threads without any problem, so what am I doing wrong.

Now, I'm not brilliant at C++, particularly on a Windows platform, so please go easy on me, as it's probably something really obvious and stupid.

Here's a fragment of my timer code:

//START OF CODE<br />
DWORD WINAPI TimerFunction(void* pParam)<br />
{<br />
   CThreadTimer* obj = (CThreadTimer*) pParam;<br />
   BOOLEAN isActive = TRUE;<br />
   do<br />
      {<br />
      Sleep(obj->elapse);<br />
<br />
      EnterCriticalSection(&obj->lock);<br />
      isActive = obj->isActive;<br />
      LeaveCriticalSection(&obj->lock);<br />
      if(isActive){<br />
         CTimerRoutines* ctr = (CTimerRoutines*) obj->object;<br />
         if(ctr->TimerHandler())<br />
            PostMessage(obj->ghMsgWnd, UM_TRIGEVENT, (WPARAM) NULL, (LPARAM) NULL);<br />
      }<br />
   } while ( isActive );<br />
<br />
   return 0;<br />
}<br />
// END OF CODE


CTimerRoutines contains my data handling routines, but the problem lies somewhere in the PostMessage call.

Any help appreciated.
GeneralRe: Multi-threading problem Pin
valikac24-Nov-03 5:39
valikac24-Nov-03 5:39 
GeneralRe: Multi-threading problem Pin
BHulme24-Nov-03 6:30
BHulme24-Nov-03 6:30 
GeneralRe: Multi-threading problem Pin
John M. Drescher24-Nov-03 5:58
John M. Drescher24-Nov-03 5:58 
GeneralRe: Multi-threading problem Pin
David Crow24-Nov-03 6:00
David Crow24-Nov-03 6:00 
GeneralRe: Multi-threading problem Pin
John M. Drescher24-Nov-03 6:02
John M. Drescher24-Nov-03 6:02 
GeneralRe: Multi-threading problem Pin
BHulme24-Nov-03 6:23
BHulme24-Nov-03 6:23 
GeneralRe: Multi-threading problem Pin
John M. Drescher24-Nov-03 6:30
John M. Drescher24-Nov-03 6:30 
GeneralRe: Multi-threading problem Pin
John M. Drescher24-Nov-03 7:04
John M. Drescher24-Nov-03 7:04 
Generalterminating thread in button on-event Pin
jason9924-Nov-03 4:54
jason9924-Nov-03 4:54 
GeneralRe: terminating thread in button on-event Pin
David Crow24-Nov-03 5:15
David Crow24-Nov-03 5:15 
GeneralRe: terminating thread in button on-event Pin
jason9924-Nov-03 5:25
jason9924-Nov-03 5:25 
GeneralRe: terminating thread in button on-event Pin
David Crow24-Nov-03 5:46
David Crow24-Nov-03 5:46 
GeneralRe: terminating thread in button on-event Pin
valikac24-Nov-03 5:41
valikac24-Nov-03 5:41 
GeneralRe: terminating thread in button on-event Pin
Mike Dimmick24-Nov-03 5:49
Mike Dimmick24-Nov-03 5:49 
GeneralRe: terminating thread in button on-event Pin
David Crow24-Nov-03 5:52
David Crow24-Nov-03 5:52 
GeneralRe: terminating thread in button on-event Pin
Anonymous24-Nov-03 6:54
Anonymous24-Nov-03 6:54 
Generaldoubts with ShellExecuteEx Pin
chadell24-Nov-03 4:37
chadell24-Nov-03 4:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.