Working on a .NET app, I've run in a 'cross-thread operation not valid' exception, only it seems to happen in the correct thread. Is there a way to find out which thread is the one where a specific control has been created?
What I've found so far:
The 'InvokeRequired' operation only tells IF the current thread is the "owner thread"...
A bit of fun time with Reflector on the Control.Invoke(...)
method got me to a P/Invoke method in user32.dll that gets the thread Id from a window handle:
[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern int GetWindowThreadProcessId(HandleRef hWnd, out int lpdwProcessId);