interprocess - Talking to unmanaged process from .NET -
i'm creating process .net using process.start. new process legacy app, written in c/c++. communicate it, need equivalent of postthreadmessage primary thread.
i'd happy use p/invoke call postthreadmessage, can't see how find primary thread. process object has collection of threads, doc says first item in collection need not primary thread. thread objects don't seem have indication of whether they're primary. , while @ thread collection after creating process, that's no guarantee there one.
so, there way me determine process' primary thread .net, or need resort using win32's createprocess?
thanks,
bob
if process has window, can use getwindowthreadprocessid
api gui thread, primary thread (use process.mainwindowhandle
window handle).
another option enumerate threads (process.threads
) , pick first 1 started, based on starttime
:
process process = process.start(...); process.waitforinputidle(); processthread primarythread = process.threads.orderby(t => t.starttime).first();
but it's not accurate technique...
Comments
Post a Comment