From a338e594273bda039eec784ecb461395f23bd56e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 17 May 2012 15:50:17 +0000 Subject: - missing plugins added - fixes for the status plugins' projects - other VS2010 projects cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@13 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/dbeditorpp/threads.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 plugins/dbeditorpp/threads.cpp (limited to 'plugins/dbeditorpp/threads.cpp') diff --git a/plugins/dbeditorpp/threads.cpp b/plugins/dbeditorpp/threads.cpp new file mode 100644 index 0000000000..7ac144adc4 --- /dev/null +++ b/plugins/dbeditorpp/threads.cpp @@ -0,0 +1,48 @@ +#include "headers.h" + +// thread stuff + +struct FORK_ARG { + HANDLE hEvent; + void (__cdecl *threadcode)(void*); + unsigned (__stdcall *threadcodeex)(void*); + void *arg; +}; + +void __cdecl forkthread_r(void *param) +{ + struct FORK_ARG *fa=(struct FORK_ARG*)param; + void (*callercode)(void*)=fa->threadcode; + void *arg=fa->arg; + + CallService(MS_SYSTEM_THREAD_PUSH,0,0); + + SetEvent(fa->hEvent); + + __try { + callercode(arg); + } __finally { + CallService(MS_SYSTEM_THREAD_POP,0,0); + } + + return; +} + +unsigned long forkthread ( void (__cdecl *threadcode)(void*),unsigned long stacksize,void *arg) +{ + unsigned long rc; + struct FORK_ARG fa; + + fa.hEvent=CreateEvent(NULL,FALSE,FALSE,NULL); + fa.threadcode=threadcode; + fa.arg=arg; + + rc=_beginthread(forkthread_r,stacksize,&fa); + + if ((unsigned long)-1L != rc) { + WaitForSingleObject(fa.hEvent,INFINITE); + } + CloseHandle(fa.hEvent); + + return rc; +} -- cgit v1.2.3