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

C / C++ / MFC

 
GeneralRe: [C]Problem in creating a random string Pin
Daniel Pfeffer27-Oct-16 5:11
professionalDaniel Pfeffer27-Oct-16 5:11 
AnswerRe: [C]Problem in creating a random string Pin
Krishnakumartg27-Oct-16 20:18
Krishnakumartg27-Oct-16 20:18 
GeneralRe: [C]Problem in creating a random string Pin
k505428-Oct-16 4:59
mvek505428-Oct-16 4:59 
PraiseRe: [C]Problem in creating a random string Pin
Krishnakumartg30-Oct-16 18:50
Krishnakumartg30-Oct-16 18:50 
QuestionRe: [C]Problem in creating a random string Pin
David Crow31-Oct-16 2:31
David Crow31-Oct-16 2:31 
QuestionUsing COM in DLL called by .Net application Pin
Leif Simon Goodwin26-Oct-16 3:02
Leif Simon Goodwin26-Oct-16 3:02 
AnswerRe: Using COM in DLL called by .Net application Pin
Richard Deeming26-Oct-16 3:11
mveRichard Deeming26-Oct-16 3:11 
PraiseSOLVED Pin
Leif Simon Goodwin9-Nov-16 5:32
Leif Simon Goodwin9-Nov-16 5:32 
Thanks for the comments. I have tested using a simple Win32 C++ console application to drive our DLL, and it works fine when using the worker thread to invoke COM commands to the third party component. So clearly this is something to do with the .Net application.

Okay, I have solved it.

A COM STA uses Windows messages to serialise access to the COM object which might not be thread safe. So when I created a worker thread, the main thread then hung waiting for the worker thread to finish, but it never did, as the main thread hanging blocked the message pump! Instead of the main thread waiting, I now make it periodically run a message pump to ensure that messages are process. That has solved the problem. Yikes. I hate COM!

Thank you for your helpful post.

Added later: I have also looked into removing the worker thread and marshalling the COM interfaces across threads and this works. It has the advantage that I do not have to mess around with a message pump, which is akin to spinning the tyres.

modified 10-Nov-16 10:36am.

AnswerRe: Using COM in DLL called by .Net application Pin
«_Superman_»26-Oct-16 20:47
professional«_Superman_»26-Oct-16 20:47 
GeneralRe: Using COM in DLL called by .Net application Pin
Leif Simon Goodwin8-Nov-16 20:53
Leif Simon Goodwin8-Nov-16 20:53 
QuestionError in returning array of int as reference Pin
Korowai22-Oct-16 19:35
Korowai22-Oct-16 19:35 
AnswerRe: Error in returning array of int as reference Pin
Graham Breach22-Oct-16 21:46
Graham Breach22-Oct-16 21:46 
GeneralRe: Error in returning array of int as reference Pin
Korowai22-Oct-16 22:41
Korowai22-Oct-16 22:41 
GeneralRe: Error in returning array of int as reference Pin
Midi_Mick22-Oct-16 23:12
professionalMidi_Mick22-Oct-16 23:12 
GeneralRe: Error in returning array of int as reference Pin
Korowai23-Oct-16 2:39
Korowai23-Oct-16 2:39 
GeneralRe: Error in returning array of int as reference Pin
leon de boer23-Oct-16 4:24
leon de boer23-Oct-16 4:24 
GeneralRe: Error in returning array of int as reference Pin
Korowai23-Oct-16 8:11
Korowai23-Oct-16 8:11 
GeneralRe: Error in returning array of int as reference Pin
Korowai23-Oct-16 8:26
Korowai23-Oct-16 8:26 
QuestionRe: Error in returning array of int as reference Pin
David Crow23-Oct-16 15:26
David Crow23-Oct-16 15:26 
AnswerRe: Error in returning array of int as reference Pin
Joe Woodbury24-Oct-16 14:07
professionalJoe Woodbury24-Oct-16 14:07 
QuestionMost efficient way to create a string range in C? Pin
Member 1280348819-Oct-16 10:19
Member 1280348819-Oct-16 10:19 
AnswerRe: Most efficient way to create a string range in C? Pin
leon de boer19-Oct-16 19:33
leon de boer19-Oct-16 19:33 
AnswerRe: Most efficient way to create a string range in C? Pin
leon de boer20-Oct-16 21:14
leon de boer20-Oct-16 21:14 
AnswerRe: Most efficient way to create a string range in C? Pin
Joe Woodbury26-Oct-16 12:16
professionalJoe Woodbury26-Oct-16 12:16 
QuestionHow to invoke Printing Preferences for the given Printer programmatically? Pin
purnachandra505016-Oct-16 17:48
purnachandra505016-Oct-16 17:48 

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.