Hi, set a breakpoint in the appropriate WaitCommEvent() event type result evaluation. This is usually switch( EvtMask) where you determine the type of event. Run the debuggee. When the debugger breaks on the specified event type, simply suspend the other threads. "Debug" -> "Threads" ... "suspend" all by looking at "location" where the functions are listed that each thread executed (before break). By doing this you save yourself from hassle that is when single stepping thru one thread you end up in another thread and so on (of course its multithreaded). Hope this helps. A. Focht.
Focht
Posts
-
how to debug multity threads -
Enumerating open handleHi, the mechanism that sysinternals and other commercial/freeware apps use is covered in an article at http://www.codeguru.com/files/FileObjectInfo.shtml . Of course it is not limited to process file handles only. You could enumerate all types of system handles that way. It works for NT-based systems only as far as i know. For Win XX there are some special deviceIo requests to get that information. Cheers, A.Focht.
-
Weird thread parameter problemHiya, at first - Visual Basic only supports Apartment-model even if "free threaded" is preferred in registry. When you create additional threads in your COM app, care must be taken when calling any methods/events from that threads. Without looking into sample code, i would guess the apartment instance pointer, your 'this' must be wrapped/marshalled in some way when it was invoked from the STA vb app (in a free threaded app, it would be marshalled for the random RPC thread). This means the interface pointer is a temporary one (limted lifetime and scope) than the CreateInstance()/OnFinalConstruct() one. When you CreateThread(), the (worker)thread function itself is not guaranteed to execute with the supplied 'this' while the method scope isnt left. When the method scope is left with "return S_OK", the internal COM/RPC invocations are returning too, possibly destroying any temporary (interface) pointers, freeing memory etc. The case that OnFinalConstruct() works may be an exception, possibly COM-apartment issues. You may compare both 'this' pointers (from OnFinalConstruct() and method invocation). If you *really* need additional threads in your COM server, then follow the threading rules (marshal interface ptrs or synchronize via postmessage to main STA thread or use static instance 'this'). There exist some MSDN articles regarding asynchronous COM and threading. Hope this helps, A. Focht