rdpChannels* channels;
instance = (freerdp*) lpParam;
+ assert(NULL != instance);
+
wfc = (wfContext*) instance->context;
+ assert(NULL != wfc);
ZeroMemory(rfds, sizeof(rfds));
ZeroMemory(wfds, sizeof(wfds));
}
/* cleanup */
- wfc->mainThreadId = 0;
-
freerdp_channels_close(channels, instance);
freerdp_disconnect(instance);
printf("Main thread exited.\n");
+ ExitThread(0);
+
return 0;
}
HHOOK hook_handle;
wfc = (wfContext*) lpParam;
+ assert(NULL != wfc);
hook_handle = SetWindowsHookEx(WH_KEYBOARD_LL, wf_ll_kbd_proc, wfc->hInstance, 0);
fprintf(stderr, "failed to install keyboard hook\n");
}
- wfc->keyboardThreadId = 0;
printf("Keyboard thread exited.\n");
+ ExitThread(0);
return (DWORD) NULL;
}
{
wfContext* wfc = (wfContext*) context;
- if (wfc->mainThreadId)
+ if (wfc->thread)
+ {
PostThreadMessage(wfc->mainThreadId, WM_QUIT, 0, 0);
- if (wfc->keyboardThreadId)
+ WaitForSingleObject(wfc->thread, INFINITE);
+ CloseHandle(wfc->thread);
+ wfc->thread = NULL;
+ wfc->mainThreadId = 0;
+ }
+
+ if (wfc->keyboardThread)
+ {
PostThreadMessage(wfc->keyboardThreadId, WM_QUIT, 0, 0);
+ WaitForSingleObject(wfc->keyboardThread, INFINITE);
+ CloseHandle(wfc->keyboardThread);
+
+ wfc->keyboardThread = NULL;
+ wfc->keyboardThreadId = 0;
+ }
+
return 0;
}