Frage

I need to obtain the Thread Id from a window create in runtime with this code

System.Windows.Window MyWindow = new System.Windows.Window();
MyWindow.Show();

I'm getting the window handler using

IntPtr WindowHandle = (new WindowInteropHelper(MyWindow)).Handle;

How can I get the Thread Id from the window or its corresponding handler?

War es hilfreich?

Lösung

Take a look at GetWindowThreadProcessId method

According to MSDN

Retrieves the identifier of the thread that created the specified window and, optionally, the identifier of the process that created the window.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top