예제 #1
0
//-----------------------------------------------------------------------------
// Name: 
// Desc:
//-----------------------------------------------------------------------------
HRESULT CFileWatch::Cleanup()
{
    if( m_hFileChangeThread )
    {
        PostThreadMessage( m_dwFileChangeThreadId, WM_QUIT, 0, 0 );
        WaitForSingleObject( m_hFileChangeThread, INFINITE );
        CloseHandle( m_hFileChangeThread );
        m_hFileChangeThread = NULL;
    }

    return S_OK;
}
// Called from the Java Swing dispatch thread
void
DesktopIndicatorHandler::enable
(JNIEnv *jniEnv)
{
    g_desktopIndicatorThread.MakeSureThreadIsUp(jniEnv);
    while (!PostThreadMessage(
            g_desktopIndicatorThread.getWinThreadId(),
            WM_DESKTOPINDICATOR, (WPARAM)enableCode,
            (LPARAM)this)) {
        Sleep(0); //Yield to other threads with any priority
    }
}
예제 #3
0
파일: w32notify.c 프로젝트: bgamari/emacs
/* Signal to the main thread that we have file notifications for it to
   process.  */
static void
send_notifications (BYTE *info, DWORD info_size, void *desc,
                    volatile int *terminate)
{
    int done = 0;
    struct frame *f = SELECTED_FRAME ();

    /* A single buffer is used to communicate all notifications to the
       main thread.  Since both the main thread and several watcher
       threads could be active at the same time, we use a critical area
       and an "in-use" flag to synchronize them.  A watcher thread can
       only put its notifications in the buffer if it acquires the
       critical area and finds the "in-use" flag reset.  The main thread
       resets the flag after it is done processing notifications.

       FIXME: is there a better way of dealing with this?  */
    while (!done && !*terminate)
    {
        enter_crit ();
        if (!notification_buffer_in_use)
        {
            if (info_size)
                memcpy (file_notifications, info, info_size);
            notifications_size = info_size;
            notifications_desc = desc;
            /* If PostMessage fails, the message queue is full.  If that
               happens, the last thing they will worry about is file
               notifications.  So we effectively discard the
               notification in that case.  */
            if ((FRAME_TERMCAP_P (f)
                    /* We send the message to the main (a.k.a. "Lisp")
                    thread, where it will wake up MsgWaitForMultipleObjects
                      inside sys_select, causing it to report that there's
                      some keyboard input available.  This will in turn cause
                      w32_console_read_socket to be called, which will pick
                      up the file notifications.  */
                    && PostThreadMessage (dwMainThreadId, WM_EMACS_FILENOTIFY, 0, 0))
                    || (FRAME_W32_P (f)
                        && PostMessage (FRAME_W32_WINDOW (f),
                                        WM_EMACS_FILENOTIFY, 0, 0))
                    /* When we are running in batch mode, there's no one to
                    send a message, so we just signal the data is
                     available and hope sys_select will be called soon and
                     will read the data.  */
                    || (FRAME_INITIAL_P (f) && noninteractive))
                notification_buffer_in_use = 1;
            done = 1;
        }
        leave_crit ();
        if (!done)
            Sleep (5);
    }
}
예제 #4
0
파일: dsp.cpp 프로젝트: madnessw/thesnow
void DspCloseLibrary()
#ifdef USE_A_THREAD
{
	if(!dspPluginEnabled) return ;

	PostThreadMessage(UpdateThreadId,WM_QUIT,0,0);
	running=false;
	if(WaitForSingleObject(hUpdateThread,1000)==WAIT_TIMEOUT)
	{
		TerminateThread(hUpdateThread,1);
	}
}
예제 #5
0
static void OnCommand(HWND hwnd, int id)
{
	if( id == ID_EXIT ) {
		Shutdown();
	}
	else if (id == ID_SHOWCONSOLE )
		ShowWindow(gui.hwnd, SW_SHOW);
	else if (id == ID_RELOAD )
		PostThreadMessage(mainThreadId,WM_COMMAND, RELOADLUA, NULL);
	else if (id == ID_HIDECONSOLE )
		ShowWindow(gui.hwnd, SW_HIDE);
}
예제 #6
0
int CSound::Stop()
{
	if(!m_pSecondaryBuffer) return CS_E_NULL_SECONDARY;
	if( m_isStreamFile ){
		PostThreadMessage(m_dwThreadId, CSL_MSG_STOP, 0, 0);
		WaitForSingleObject(m_hThreadMessageDispatchEvent, INFINITE);
	}else{
		m_pSecondaryBuffer->Stop();
		this->StopDuplicatedBuffer();	//まさか複製バッファの音だけ残しておきたいとか無いでしょ・・・
	}
	return CS_E_OK;
}
예제 #7
0
LPTIMECALLBACK setitimer_timeout(UINT uTimerID, UINT info, DWORD dwUser, DWORD dw1, DWORD dw2)
{
	struct timer_msg *msg = (struct timer_msg *) info;

	if (msg) {
		raise((int) msg->signal);
		PostThreadMessage(msg->threadid,
						  WM_NOTIFY, msg->signal, 0);
		free(msg);
	}
	return 0;
}
예제 #8
0
int clear_hook(void)
{
    if(mouse_ll_hook == NULL) {
        return 1;
    }

    PostThreadMessage(hook_thread_id, HOOK_THREAD_END, 0, 0);
    WaitForSingleObject(hook_thread_end_evt, INFINITE);
    CloseHandle(hook_thread_end_evt);

    return 1;
}
예제 #9
0
파일: js_wimg.cpp 프로젝트: z4y4/njord
void wimfilecleanup(JSContext * cx, JSObject * obj)
{
    HANDLE wimHandle = JS_GetPrivate(cx, obj);
    if(wimHandle == NULL)
        return;
    if(threadID != 0)
    {
        while(!PostThreadMessage(threadID, WM_APP + 2, 0, (LPARAM)wimHandle))
            Sleep(200);
    }
    WIMUnregisterMessageCallback(wimHandle, NULL);
    WIMCloseHandle(wimHandle);
}
예제 #10
0
CCoFAHost::~CCoFAHost()
{
    TRY_CATCH
    Log.Add(_MESSAGE_,_T("CCoFAHost::~CCoFAHost()"));

    PostThreadMessage(GetTid(), WM_QUIT, 0, 0);
    m_brokerEvents.Revoke();

//	if( m_server.get() )
//		m_server->Stop();

    CATCH_LOG()
}
예제 #11
0
파일: libnotify.c 프로젝트: sria91/artha
LIBNOTIFY_API gboolean notify_notification_close(
	NotifyNotification *notification, GError **error)
{
	UNREFERENCED_PARAMETER(error);

	if(notification_thread && notification)
		return PostThreadMessage(notification_thread_id,
								 WM_LIBNOTIFYCLOSE,
								 0,
								 (LPARAM) notification);

	return FALSE;
}
예제 #12
0
int d3d::EnterMsgLoop()
{
	MSG msg;
	::ZeroMemory(&msg, sizeof(MSG));

	timeBeginPeriod(1);
	unsigned int thid;

	g_ThreadCnt++;
	_beginthreadex(NULL, 0, GameLoop,NULL,0,&thid);
	while(msg.message != WM_QUIT)
	{
		if(::PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
		{
			if(msg.message == WM_KEYDOWN || msg.message == WM_CHAR || (msg.message == WM_KEYUP && (msg.wParam == VK_SHIFT || msg.wParam == VK_CONTROL)))
				PostThreadMessage(thid,msg.message,msg.wParam,msg.lParam);
			::TranslateMessage(&msg);
			::DispatchMessage(&msg);
		}
		Sleep(16);	
		if(!Display(0))
		{
			::MessageBox(0, "디스플레이 에러", 0, 0);
		}
		if(!g_ThreadCnt)
			break;
		//if(0)
		//{
		//	PostQuitMessage(0);
		//}
    }
	PostThreadMessage(thid,WM_QUIT,msg.wParam,msg.lParam);
	int i=0;
	while(g_ThreadCnt > 0 && i++ <= 50)
		Sleep(200);
	if(i>50)
		::MessageBox(0, "쓰레드 종료 실패", 0, 0);
	return msg.wParam;
}
예제 #13
0
BOOL WINAPI ConsoleEventHandler(DWORD dwCtrlType)
{
	switch(dwCtrlType)
	{
		case CTRL_C_EVENT:
		case CTRL_CLOSE_EVENT:
			PostThreadMessage(dwMainThread, WM_QUIT, NULL, NULL);
			return TRUE;

		default:
			return FALSE;
	}
}
예제 #14
0
void DspCloseLibrary()
#ifdef USE_A_THREAD
{
	if(!dspPluginEnabled) return ;

	PostThreadMessage(UpdateThreadId,WM_QUIT,0,0);
	running=false;
	if(WaitForSingleObject(hUpdateThread,1000)==WAIT_TIMEOUT)
	{
		ConLog("SPU2-X: WARNING: DSP Thread did not close itself in time. Assuming hung. Terminating.\n");
		TerminateThread(hUpdateThread,1);
	}
}
/**
 * Send a message to the async window thread and wait for a reply
 *
 * @returns VBox status code.
 * @param   pWindowThread   Thread handle
 * @param   WndRequestSem   Semaphore handle for waiting
 * @param   msg             Message id
 * @param   wParam          First parameter
 * @param   lParam          Second parameter
 */
int vmsvga3dSendThreadMessage(RTTHREAD pWindowThread, RTSEMEVENT WndRequestSem, UINT msg, WPARAM wParam, LPARAM lParam)
{
    int  rc;
    BOOL ret;

    ret = PostThreadMessage(RTThreadGetNative(pWindowThread), msg, wParam, lParam);
    AssertMsgReturn(ret, ("PostThreadMessage %x failed with %d\n", RTThreadGetNative(pWindowThread), GetLastError()), VERR_INTERNAL_ERROR);

    rc = RTSemEventWait(WndRequestSem, RT_INDEFINITE_WAIT);
    Assert(RT_SUCCESS(rc));

    return rc;
}
예제 #16
0
파일: flyplus.cpp 프로젝트: jhp333/aux
void NotifyApplication(char *buffer)
{
	WORD msgSize, command;

	msgSize = *(WORD*)&buffer[0];
	command = *(WORD*)&buffer[2];

	if (blockingMode)
		PostThreadMessage (applProcID, WM_FL_ARRIVED, MAKELONG(command,msgSize), (LPARAM)(buffer+4));
	else
		SendMessage (hMom, WM_FL_ARRIVED, MAKELONG(command,msgSize), (LPARAM)(buffer+4));
	remRecvItems++;
}
void DesktopIndicatorHandler::update( jint image, const char *tooltip )
{
	m_icon = (HICON) image;

	// Free string
	if( m_tooltip )
		delete m_tooltip;

	// Copy string
	m_tooltip = strdup( tooltip );

	PostThreadMessage( g_DesktopIndicatorThread, WM_DESKTOPINDICATOR, updateCode, (LPARAM) this );
}
예제 #18
0
UIOHOOK_API int hook_stop() {
	int status = UIOHOOK_FAILURE;

	// Try to exit the thread naturally.
	if (PostThreadMessage(hook_thread_id, WM_QUIT, (WPARAM) NULL, (LPARAM) NULL)) {
		status = UIOHOOK_SUCCESS;
	}

	logger(LOG_LEVEL_DEBUG,	"%s [%u]: Status: %#X.\n",
			__FUNCTION__, __LINE__, status);

	return status;
}
예제 #19
0
/* posts the asynchronous result to its owner thread */
void asynch_post_result (ASYNCH_CALL_RESULT *result) {
#ifdef WIN32
	/*
	The result structure contains the target_thread_id member storing the thread id
	of the owner thread that started the asynchronous call. Post a message to this thread
	passing the result structure as a parameter. 

	Note that the message loop of the owner thread must process this message and dispatch,
	using asynch_dispatch_result function, the result to the acutal callback set during the 
	asynchronous call invocation.
	*/
	PostThreadMessage (result->target_thread_id, ASYNCH_CALL_MSG, 0, (LPARAM)result);
#endif
}
예제 #20
0
/*
    WaveInProc

    Posts a message to 'CaptureThreadProc' everytime a WaveIn Buffer is completed and
    returns to the application (with more data)
*/
static void CALLBACK WaveInProc(HWAVEIN hDevice,UINT uMsg,DWORD_PTR dwInstance,DWORD_PTR dwParam1,DWORD_PTR dwParam2)
{
    ALCdevice *pDevice = (ALCdevice*)dwInstance;
    WinMMData *pData = pDevice->ExtraData;

    (void)hDevice;
    (void)dwParam2;

    if(uMsg != WIM_DATA)
        return;

    InterlockedDecrement(&pData->lWaveBuffersCommitted);
    PostThreadMessage(pData->ulWaveThreadID,uMsg,0,dwParam1);
}
예제 #21
0
void wmmSoundSuspend(WmmSound* wmmSound) 
{
    if(wmmSound->hThread == NULL) {
        return;
    }

    while (0 == PostThreadMessage(wmmSound->sndThreadId, WM_USER + 1, 0, 0)) {
        Sleep(100);
    }

    WaitForSingleObject(wmmSound->hThread, INFINITE);
    CloseHandle(wmmSound->hThread);
    wmmSound->hThread = NULL;
}
예제 #22
0
파일: HelixSvc.cpp 프로젝트: smc314/helix
VOID EndProcess(int ProcessIndex)
{
	if(ProcessIndex >=0 && ProcessIndex <= MAX_NUM_OF_PROCESS)
	{
		if(pProcInfo[ProcessIndex].hProcess)
		{
			// post a WM_QUIT message first
			PostThreadMessage(pProcInfo[ProcessIndex].dwThreadId, WM_QUIT, 0, 0);
			Sleep(1000);
			// terminate the process by force
			TerminateProcess(pProcInfo[ProcessIndex].hProcess, 0);
		}
	}
}
예제 #23
0
void Module::Quit()
{
    if (m_hInstance)
    {
        if (m_dwFlags & LS_MODULE_THREADED)
        {
            PostThreadMessage(m_dwThreadID, WM_DESTROY, 0, (LPARAM)this);
        }
        else
        {
            CallQuit();
        }
    }
}
예제 #24
0
DWORD HookProc(int nCode,WPARAM wParam,LPARAM lParam)
{
 if(nCode>=0&&wParam==WM_LBUTTONDOWN)
 {
  DWORD pt[2];
  memcpy(&pt[0],(void*)lParam,8);
  if(SendMessage(GetConsoleWindow(),WM_NCHITTEST,0,(LPARAM)pt[0]+0x10000*pt[1])==HTCLOSE)
  {
   PostThreadMessage(GetCurrentThreadId(),WM_USER+1,0,0);
   return 1;
  }
 }
 return CallNextHookEx(hHook,nCode,wParam,lParam);
}
void CEditColorMapDlgThread::kill() {
  PostThreadMessage(WM_QUIT,0,0);

  for(;;) {
    DWORD exitCode = 0;
    if(!GetExitCodeThread(m_hThread, &exitCode)) {
      return;
    }
    if(exitCode != STILL_ACTIVE) {
      return;
    }
    Sleep(50);
  }
}
RECT *ServerVideoManager::newRequest(int thread_assigned)
{
	BYTE ** b=new BYTE *[3];
	b[0] = old_bmp;
	b[1] = new_bmp;
	b[2]=(BYTE *) new int(thread_assigned);

	RECT *r=getRect(current_block);

	PostThreadMessage(t[thread_assigned]->getID(),WM_THREAD,(WPARAM) b,(LPARAM) r);

	current_block++;
	return r;	// this can be used for debug
}
예제 #27
0
BOOL WINAPI OnConsoleSignal(DWORD signal)
{
    switch (signal) {
    case CTRL_C_EVENT:
    case CTRL_BREAK_EVENT:
    case CTRL_CLOSE_EVENT:
        // Force main thread to break out of message loop
        PostThreadMessage(g_mainThreadId, WM_QUIT, 0, 0);
        // Wait for main thread to clean up
        while (!g_cleanupFinished);
        break;
    }
    return FALSE;
}
예제 #28
0
	/*DLLIMPORT*/ void SetVolume(int iVolume)
	{
		if (iVolume < MIN_VOLUME)
		{
			iVolume = MIN_VOLUME;
		}
		if (iVolume > MAX_VOLUME)
		{
			iVolume = MAX_VOLUME;
		}
		g_iVolume = iVolume;
		InstallMuterHooks();
		PostThreadMessage(g_uThread, WM_USER_HOOK_PROCESSES, 0, 0);
	}
예제 #29
0
//--------------------------------------------------------------------------------
void CHL7PacOutThread::DoInit(CServerThreadInfo* pInfo, CHL7InputDaemonInit* pInitInfo)
	{
	ASSERT_VALID(this);

	GetIO()->Output(IOMASK_7|IOMASK_CONST, "CHL7PacOutThread::InitInstance entry");
	m_pInitInfo = pInitInfo;
	if(m_pInitInfo != NULL)
		GetIO()->AddThreadName(m_pInitInfo->GetName());
	m_nVersion = m_pInitInfo->GetVersion();
	m_pInfo = pInfo;
	m_evtInit.PulseEvent();
	GetIO()->Output(IOMASK_8|IOMASK_CONST, "CHL7PacOutThread::InitInstance exit");
	PostThreadMessage(HL7_GO, 0, 0);
	}
예제 #30
0
//终止线程
void CWriteLogThread::StopLog()
{
    if(m_bStartFlag)
    {
        m_bStartFlag = FALSE;
        //终止线程
        PostThreadMessage(m_dwLogThreadID, WM_THREAD_STOP, 0L, 0L);
        ::WaitForSingleObject(m_hLogThreadEndEvt, INFINITE);
        
        CloseHandle(m_hLogThreadEndEvt);
        m_hLogThreadEndEvt = NULL;
        m_dwLogThreadID = 0;
    }
}