本文整理汇总了C++中PostThreadMessage函数的典型用法代码示例。如果您正苦于以下问题:C++ PostThreadMessage函数的具体用法?C++ PostThreadMessage怎么用?C++ PostThreadMessage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PostThreadMessage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PostThreadMessage
//-----------------------------------------------------------------------------
// 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;
}
示例2: while
// 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: send_notifications
/* 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: DspCloseLibrary
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: PostThreadMessage
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;
}
示例6: setitimer_timeout
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;
}
示例7: clear_hook
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;
}
示例8: wimfilecleanup
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);
}
示例9: PostThreadMessage
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()
}
示例10: notify_notification_close
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;
}
示例11: sizeof
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;
}
示例12: ConsoleEventHandler
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;
}
}
示例13: DspCloseLibrary
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);
}
}
示例14: vmsvga3dSendThreadMessage
/**
* 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;
}
示例15: NotifyApplication
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++;
}