Click here to Skip to main content
15,887,386 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: serial port sniffer Pin
James Brown1-Mar-06 22:29
James Brown1-Mar-06 22:29 
GeneralRe: serial port sniffer Pin
szilics1-Mar-06 23:22
szilics1-Mar-06 23:22 
AnswerRe: serial port sniffer Pin
Rick York1-Mar-06 21:32
mveRick York1-Mar-06 21:32 
QuestionMultithreading Pin
Waldermort1-Mar-06 20:34
Waldermort1-Mar-06 20:34 
AnswerRe: Multithreading Pin
Naveen1-Mar-06 20:46
Naveen1-Mar-06 20:46 
GeneralRe: Multithreading Pin
Stephen Hewitt1-Mar-06 22:23
Stephen Hewitt1-Mar-06 22:23 
GeneralRe: Multithreading Pin
Naveen1-Mar-06 23:28
Naveen1-Mar-06 23:28 
AnswerRe: Multithreading Pin
Cedric Moonen1-Mar-06 21:00
Cedric Moonen1-Mar-06 21:00 
As said by Naveen, you can use CreateThread. But it requires some practise before knowing exactly how to use it in a good way (specifically if you don't want to break your OO design).
But you said that your project is non-MFC, does that means it's a console app or is it a win32 application ? If it's a console app, I don't think you can use CreateThread as it is part of the windows SDK. You'll need to use _beginthread.

Anyway, if you want to keep your OO design, the best way IMO is to make your thread run a function of your class and use a boolean to keep the status of the process (finished or not). You could also post a message to your GUI window to specify that the process is finished (or even that the process has increased of 1%). To make your thread run a member function of your class, you'll have to use a little trick: you cannot supply directly the function to the thread because it doesn't have the same prototype as a global function (implicit this parameter). Thus, you can instead use a static member functino of the class (no this parameter because static functions are shared among all instances of your class) and pass the this pointer in the parameters you can pass in the CreateThread function. Then you get it back in your static function and it lets you call a member function of the class in which you can make your process.
In this way you don't break your OO design.

If its not clear, ask and I can post some code.
GeneralRe: Multithreading Pin
Waldermort1-Mar-06 21:54
Waldermort1-Mar-06 21:54 
GeneralRe: Multithreading Pin
Cedric Moonen1-Mar-06 22:19
Cedric Moonen1-Mar-06 22:19 
AnswerRe: Multithreading Pin
Joe Woodbury1-Mar-06 21:20
professionalJoe Woodbury1-Mar-06 21:20 
Questionc++ Pin
yaaqub1-Mar-06 20:28
yaaqub1-Mar-06 20:28 
AnswerRe: c++ Pin
Nibu babu thomas1-Mar-06 20:33
Nibu babu thomas1-Mar-06 20:33 
AnswerRe: c++ Pin
Stephen Hewitt1-Mar-06 22:28
Stephen Hewitt1-Mar-06 22:28 
QuestionCombo box height is not increasing Pin
BiswaR1-Mar-06 19:45
BiswaR1-Mar-06 19:45 
AnswerRe: Combo box height is not increasing Pin
Naveen1-Mar-06 20:42
Naveen1-Mar-06 20:42 
QuestionUsing Serial Port communication for dialog based application Pin
BeakX1-Mar-06 19:44
BeakX1-Mar-06 19:44 
AnswerRe: Using Serial Port communication for dialog based application Pin
Cedric Moonen1-Mar-06 20:26
Cedric Moonen1-Mar-06 20:26 
GeneralRe: Using Serial Port communication for dialog based application Pin
Rick York1-Mar-06 21:50
mveRick York1-Mar-06 21:50 
GeneralRe: Using Serial Port communication for dialog based application Pin
Cedric Moonen1-Mar-06 22:00
Cedric Moonen1-Mar-06 22:00 
Questionhow to show images on window and move. Pin
baldha rakesh1-Mar-06 19:19
baldha rakesh1-Mar-06 19:19 
AnswerRe: how to show images on window and move. Pin
Nibu babu thomas1-Mar-06 19:54
Nibu babu thomas1-Mar-06 19:54 
GeneralRe: how to show images on window and move. Pin
baldha rakesh1-Mar-06 20:14
baldha rakesh1-Mar-06 20:14 
QuestionHow to test the MTTTY example of serial comm in Win32 console? Pin
pkyiu1-Mar-06 19:17
pkyiu1-Mar-06 19:17 
QuestionHow to convert exe to dll Pin
BicycleTheif1-Mar-06 18:38
BicycleTheif1-Mar-06 18:38 

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.