From e968628e6accb6252a2eb55eb84f4b544e84e307 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 18 Nov 2005 15:06:38 +0000 Subject: [PATCH] Avoid setting the context before the thread has started running, it's broken on most Windows versions. --- dlls/kernel/tests/thread.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dlls/kernel/tests/thread.c b/dlls/kernel/tests/thread.c index 6b268447bad..200cdf6d175 100644 --- a/dlls/kernel/tests/thread.c +++ b/dlls/kernel/tests/thread.c @@ -610,6 +610,7 @@ static VOID test_GetThreadExitCode(void) #ifdef __i386__ static int test_value = 0; +static HANDLE event; static void WINAPI set_test_val( int val ) { @@ -618,6 +619,8 @@ static void WINAPI set_test_val( int val ) static DWORD WINAPI threadFunc6(LPVOID p) { + SetEvent( event ); + Sleep( 1000 ); test_value *= (int)p; return 0; } @@ -631,13 +634,17 @@ static void test_SetThreadContext(void) DWORD prevcount; SetLastError(0xdeadbeef); - thread = CreateThread( NULL, 0, threadFunc6, (void *)2, CREATE_SUSPENDED, &threadid ); + event = CreateEvent( NULL, TRUE, FALSE, NULL ); + thread = CreateThread( NULL, 0, threadFunc6, (void *)2, 0, &threadid ); ok( thread != NULL, "CreateThread failed : (%ld)\n", GetLastError() ); if (!thread) { trace("Thread creation failed, skipping rest of test\n"); return; } + WaitForSingleObject( event, INFINITE ); + SuspendThread( thread ); + CloseHandle( event ); ctx.ContextFlags = CONTEXT_FULL; SetLastError(0xdeadbeef);