Visual Studio Development Bookmark and Share   
 index > Visual Studio Source Control and SourceSafe > [MSSCCI] Problem calling LPTEXTOUTPROC in different thread
 

[MSSCCI] Problem calling LPTEXTOUTPROC in different thread

Hi *
I'm implementing a provider using the MSSCCI. I need to call the callback function LPTEXTOUTPROC of the IDE (VS2005) in another thread. So evertime SccOpenProject ois called a new thead will be created and the function pointer is passed. Calling LPTEXTOUTPROC works great in any direct Scc* call, but somehow it's not working when called in the thread - I'm really clueless how I can make this work...
simplified, this is what I try in the scc dll:
in SccOpenProject:
...
if (lpTextOutProc != NULL){
lpTextOutProc("test",SCC_MSG_ERROR); //a test, works great
m_hCallbackDispatchThread = CreateThread( NULL, 0, callbackDispatchThreadFunc, lpTextOutProc, 0, NULL);

...
in the callbackDispatchThreadFunc:
DWORD WINAPI callbackDispatchThreadFunc( LPVOID lpParam ){
LPTEXTOUTPROC txtout = reinterpret_cast<LPTEXTOUTPROC>(lpParam);
txtout("test",SCC_MSG_ERROR); //a test, doesn't work
...

Is there any way to use the LPTEXTOUTPROC function pointer passed in SccOpenProject in another thread?
Florian
Florian.w  Wednesday, August 26, 2009 8:11 AM

Sinceyou're getting an error, it looks like the callback function can't be used from another thread (at least in VisualStudio as IDE).

I think what's going on is that VS is trying to get the Output window service (SID_SVsOutputWindow) and use it to write the message in the output window. In VS services can't be obtained directly from background threads with a simple QueryService call - they have to be marshaled, and scci code does not do that.


Even more, in VS10 with the shell being implemented as WPF, accessing the UI elements (e.g. to display the message) can only be done on the thread that created them, which is the UI/main thread. Again, in VS the scci code does not expect this function to be called from background threads and won't marshal the call back to the UI thread.

You'll have to do the thread synchronization/call marshaling yourself in the MSSCCI provider code, and do the textout callback from the main thread.

Alin

Alin Constantin  Friday, August 28, 2009 5:27 PM

Sinceyou're getting an error, it looks like the callback function can't be used from another thread (at least in VisualStudio as IDE).

I think what's going on is that VS is trying to get the Output window service (SID_SVsOutputWindow) and use it to write the message in the output window. In VS services can't be obtained directly from background threads with a simple QueryService call - they have to be marshaled, and scci code does not do that.


Even more, in VS10 with the shell being implemented as WPF, accessing the UI elements (e.g. to display the message) can only be done on the thread that created them, which is the UI/main thread. Again, in VS the scci code does not expect this function to be called from background threads and won't marshal the call back to the UI thread.

You'll have to do the thread synchronization/call marshaling yourself in the MSSCCI provider code, and do the textout callback from the main thread.

Alin

Alin Constantin  Friday, August 28, 2009 5:27 PM
Hi Alin,

Many thanks for the information, I assumed the Marshalling would be the reason, but not sure. Now it's clear. :-)

Sincerely,
Wesley
Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Wesley Yao  Monday, August 31, 2009 2:57 AM
Hi Wesley, hi Alin,

as usual: many thank for the answer! I really appreciate your fast replies.
Regarding the function call: I already feared, it wouldn't be possible to solve this the easy way - I forward the MSSCCI calls to to a Java component, which is responsible for processing the call. This is done synchronously via JNI :/
So it seems, there is no way around the threading-game.

Thanks again

Sincerely,
Florian
Florian.w  Wednesday, September 02, 2009 1:00 PM

You can use google to search for other answers

Custom Search

More Threads

• Get Latest Version For Shared Files Works From VSS Explorer, Broken In VS2008?
• ClearCase integration issues
• To get/set comments on VSS Item Programmatically
• SourceSafe 2005 with Visual Studio 2003
• How to place random numbers in labels?
• Visual SourceSafe Internet troubles
• How to checkin , checkout and view the files from VSS database(Server) , without client installation, i.e through coding ?
• When opening project which was checked out disconnected, lose Network Connection
• Internet-remoting setup in VS 2005-client.
• Destroy Permanently files and VSS Backup Solutions