当前位置: 首页>>代码示例>>C++>>正文


C++ SetEvent函数代码示例

本文整理汇总了C++中SetEvent函数的典型用法代码示例。如果您正苦于以下问题:C++ SetEvent函数的具体用法?C++ SetEvent怎么用?C++ SetEvent使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SetEvent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: EnterCriticalSection

void StatusWindow::SendCommand(StatusCommand *_command)
{
	if(hasFailed) {
		return;
	}

	EnterCriticalSection(&csReentrant);
	EnterCriticalSection(&csThreadAlive);

	if(!threadAlive) {
		if(otherThread != NULL) {
			CloseHandle(otherThread);
		}

		ResetEvent(eventCommandSent);
		ResetEvent(eventCommandAcknowledged);

		otherThread = CreateThread(NULL, 0, StatusWindow::ThreadProc, (LPVOID)this, 0, NULL);
		if(otherThread == NULL) {
			hasFailed = true;
			LeaveCriticalSection(&csReentrant);
			LeaveCriticalSection(&csThreadAlive);
			return;
		}

		CommandInit cmdInit;
		command = &cmdInit;
		SetEvent(eventCommandSent);

		DWORD rv;
		rv = WaitForSingleObject(eventCommandAcknowledged, 10000);
		if(rv != WAIT_OBJECT_0) {
			MessageBox(parentWindow, "Error while waiting for new thread.\r\n\r\nThere may be a stray thread lying around now,\r\nSuggest closing 3D Studio and checking the process list.", "Error", MB_OK | MB_ICONERROR);
			TerminateThread(otherThread, 0);
			CloseHandle(otherThread);
			hasFailed = true;
			LeaveCriticalSection(&csReentrant);
			LeaveCriticalSection(&csThreadAlive);
			return;
		}

		threadAlive = true;
	}
	
	command = _command;
	if(command->type == StatusCommand::COMMAND_CLOSE)
		threadAlive = false;

	SetEvent(eventCommandSent);
	DWORD rv;
	rv = WaitForSingleObject(eventCommandAcknowledged, 10000);
	if(rv != WAIT_OBJECT_0) {
			MessageBox(parentWindow, "Error while waiting for new thread.\r\n\r\nThere may be a stray thread lying around now,\r\nSuggest closing 3D Studio and checking the process list.", "Error", MB_OK | MB_ICONERROR);
			TerminateThread(otherThread, 0);
			CloseHandle(otherThread);
			hasFailed = true;
			LeaveCriticalSection(&csReentrant);
			LeaveCriticalSection(&csThreadAlive);
			return;		
	}
	
	LeaveCriticalSection(&csThreadAlive);
	LeaveCriticalSection(&csReentrant);
}
开发者ID:FujiGameJam,项目名称:fuji,代码行数:64,代码来源:StatusWindow.cpp

示例2: SetEvent

void CAudioCapture::Cancel(void)
{
	if (m_hEvents[CANCEL_EVENT])
		SetEvent(m_hEvents[CANCEL_EVENT]);
}
开发者ID:Gaurav2728,项目名称:rhodes,代码行数:5,代码来源:AudioCapturenew.cpp

示例3: window_proc


//.........这里部分代码省略.........
        switch(wParam) {
        case IDM_ABOUT:
            DialogBox(ghInst, TEXT("AboutBox"), main_window_handle,
                (DLGPROC)about_proc);
            break;
        case IDM_SHOW_LOG:
            if(visible) {
                ShowWindow(main_window_handle, SW_HIDE); /* hide window */
            } else {
                ShowWindow(main_window_handle, SW_SHOWNORMAL); /* show window */
                SetForegroundWindow(main_window_handle); /* bring on top */
            }
            break;
        case IDM_CLOSE:
            ShowWindow(main_window_handle, SW_HIDE); /* hide window */
            break;
        case IDM_EXIT:
            if(!error_mode) /* signal_pipe is active */
                signal_post(SIGNAL_TERMINATE);
            DestroyWindow(main_window_handle);
            break;
        case IDM_SAVE_LOG:
            if(!cmdline.service) /* security */
                save_log();
            break;
        case IDM_EDIT_CONFIG:
#ifndef _WIN32_WCE
            if(!cmdline.service) /* security */
                edit_config(main_window_handle);
#endif
            break;
        case IDM_RELOAD_CONFIG:
            if(error_mode) /* unlock daemon_thread */
                SetEvent(config_ready);
            else /* signal_pipe is active */
                signal_post(SIGNAL_RELOAD_CONFIG);
            break;
        case IDM_REOPEN_LOG:
            signal_post(SIGNAL_REOPEN_LOG);
            break;
        case IDM_MANPAGE:
#ifndef _WIN32_WCE
            if(!cmdline.service) /* security */
                ShellExecute(main_window_handle, TEXT("open"),
                    TEXT("stunnel.html"), NULL, NULL, SW_SHOWNORMAL);
#endif
            break;
        case IDM_HOMEPAGE:
#ifndef _WIN32_WCE
            if(!cmdline.service) /* security */
                ShellExecute(main_window_handle, TEXT("open"),
                    TEXT("http://www.stunnel.org/"), NULL, NULL, SW_SHOWNORMAL);
#endif
            break;
        }
        return TRUE;

    case WM_SYSTRAY: /* a taskbar event */
        switch(lParam) {
#ifdef _WIN32_WCE
        case WM_LBUTTONDOWN: /* no right mouse button on Windows CE */
            GetWindowRect(GetDesktopWindow(), &rect); /* no cursor position */
            pt.x=rect.right;
            pt.y=rect.bottom-25;
#else
        case WM_RBUTTONDOWN:
开发者ID:pantheon-systems,项目名称:stunnel-dev,代码行数:67,代码来源:ui_win_gui.c

示例4: freerdp_connect


//.........这里部分代码省略.........

	status = rdp_client_connect(rdp);

	/* --authonly tests the connection without a UI */
	if (instance->settings->AuthenticationOnly)
	{
		WLog_ERR(TAG, "Authentication only, exit status %"PRId32"", !status);
		goto freerdp_connect_finally;
	}

	if (!status)
		goto freerdp_connect_finally;

	if (status)
	{
		UINT status2;

		if (instance->settings->DumpRemoteFx)
		{
			instance->update->pcap_rfx = pcap_open(instance->settings->DumpRemoteFxFile,
			                                       TRUE);

			if (instance->update->pcap_rfx)
				instance->update->dump_rfx = TRUE;
		}

		IFCALLRET(instance->PostConnect, status, instance);

		if (status)
			status2 = freerdp_channels_post_connect(instance->context->channels, instance);

		if (!status || (status2 != CHANNEL_RC_OK)
		    || !update_post_connect(instance->update))
		{
			WLog_ERR(TAG, "freerdp_post_connect failed");

			if (!freerdp_get_last_error(rdp->context))
				freerdp_set_last_error(instance->context, FREERDP_ERROR_POST_CONNECT_FAILED);

			status = FALSE;
			goto freerdp_connect_finally;
		}

		if (instance->settings->PlayRemoteFx)
		{
			wStream* s;
			rdpUpdate* update;
			pcap_record record;
			update = instance->update;
			update->pcap_rfx = pcap_open(settings->PlayRemoteFxFile, FALSE);

			if (!update->pcap_rfx)
			{
				status = FALSE;
				goto freerdp_connect_finally;
			}
			else
			{
				update->play_rfx = TRUE;
			}

			while (pcap_has_next_record(update->pcap_rfx))
			{
				pcap_get_next_record_header(update->pcap_rfx, &record);

				if (!(s = StreamPool_Take(rdp->transport->ReceivePool, record.length)))
					break;

				record.data = Stream_Buffer(s);
				pcap_get_next_record_content(update->pcap_rfx, &record);
				Stream_SetLength(s, record.length);
				Stream_SetPosition(s, 0);
				update->BeginPaint(update->context);
				update_recv_surfcmds(update, s);
				update->EndPaint(update->context);
				Stream_Release(s);
			}

			pcap_close(update->pcap_rfx);
			update->pcap_rfx = NULL;
			status = TRUE;
			goto freerdp_connect_finally;
		}
	}

	if (rdp->errorInfo == ERRINFO_SERVER_INSUFFICIENT_PRIVILEGES)
		freerdp_set_last_error(instance->context,
		                       FREERDP_ERROR_INSUFFICIENT_PRIVILEGES);

	SetEvent(rdp->transport->connectedEvent);
freerdp_connect_finally:
	EventArgsInit(&e, "freerdp");
	e.result = status ? 0 : -1;
	PubSub_OnConnectionResult(instance->context->pubSub, instance->context, &e);

	if (!status)
		freerdp_disconnect(instance);

	return status;
}
开发者ID:jat255,项目名称:FreeRDP,代码行数:101,代码来源:freerdp.c

示例5: kmmint_exit_module


//.........这里部分代码省略.........

        m->state = KMM_MODULE_STATE_EXITPLUG;

        p = kmm_listed_plugins;

        while(p) {
            if(p->module == m &&
               (p->flags & KMM_PLUGIN_FLAG_IN_MODCOUNT)) {

                kmm_hold_plugin(kmm_handle_from_plugin(p));
                kmq_post_message(KMSG_KMM, KMSG_KMM_I_REG, 
                                 KMM_REG_EXIT_PLUGIN, (void *) p);
                np++;

            }

            p = LNEXT(p);
        }

#ifdef DEBUG
        assert(np == m->plugin_count);
#endif

        if(np > 0) {
            /*  we have to go back and wait for the plugins to exit.
                when the last plugin exits, it automatically posts
                EXIT_MODULE. We can pick up from there when this
                happens. */
            LeaveCriticalSection(&cs_kmm);
            return;
        }

    } else {

#ifdef DEBUG
        assert(m->plugin_count == 0 ||
               m->state == KMM_MODULE_STATE_EXITPLUG);
#endif

        /* if there are still plug-ins waiting to be unloaded, then we
           have to go back and wait for them to finish.  Once they are
           done, kmmint_exit_module() will get called again. */
        if (m->plugin_count > 0) {
            LeaveCriticalSection(&cs_kmm);
            return;
        }
    }

    if(m->flags & KMM_MODULE_FLAG_INITP) {
        exit_module_t p_exit_module;

        if(m->state > 0)
            m->state = KMM_MODULE_STATE_EXIT;

        p_exit_module = 
            (exit_module_t) GetProcAddress(m->h_module, 
                                           EXP_EXIT_MODULE);
        if(p_exit_module) {
            LeaveCriticalSection(&cs_kmm);
            (*p_exit_module)(kmm_handle_from_module(m));
            EnterCriticalSection(&cs_kmm);
        }
    }

    if(m->state > 0)
        m->state = KMM_MODULE_STATE_EXITED;

    LeaveCriticalSection(&cs_kmm);

    if(!(m->flags & KMM_MODULE_FLAG_NOUNLOAD) &&
       m->h_module) {
        FreeLibrary(m->h_module);
    }

    if(!(m->flags & KMM_MODULE_FLAG_NOUNLOAD) &&
       m->h_resource && (m->h_resource != m->h_module)) {
        FreeLibrary(m->h_resource);
    }

    m->h_module = NULL;
    m->h_resource = NULL;

    if (m->flags & KMM_MODULE_FLAG_LOADED) {
#ifdef DEBUG
        assert(kmm_active_modules > 0);
#endif
        kmm_active_modules--;
    }

    m->flags = 0;

    /* release the hold obtained in kmmint_init_module() */
    kmm_release_module(kmm_handle_from_module(m));

    /* Last but not least, now see if there are any modules left that
       are running. If not, we can safely signal an exit. */
    if (kmm_active_modules == 0) {
        SetEvent(evt_exit);
    }
}
开发者ID:FarazShaikh,项目名称:LikewiseSMB2,代码行数:101,代码来源:kmm_registrar.c

示例6: WIN_cond_signal

int WIN_cond_signal(ortp_cond_t * hCond)
{
	SetEvent(*hCond);
	return 0;
}
开发者ID:cybertk,项目名称:blackberry-linphone,代码行数:5,代码来源:port.c

示例7: MrvDrvSend


//.........这里部分代码省略.........
                                  pHeader[13]));
            return NDIS_STATUS_FAILURE;
        }
     }// if ( (Adapter->EncryptionStatus == Ndis802_11Encryption2KeyAbsent )|| (Adapter->EncryptionStatus == Ndis802_11Encryption3KeyAbsent ) )  
                       
if(Adapter->TCloseWZCFlag==WZC_Ignore_Send_EAPOL_START)
{
 if ( (Adapter->EncryptionStatus == Ndis802_11Encryption2Enabled )||(Adapter->EncryptionStatus == Ndis802_11Encryption2KeyAbsent )||(Adapter->EncryptionStatus == Ndis802_11Encryption3Enabled )||(Adapter->EncryptionStatus == Ndis802_11Encryption3KeyAbsent )  )  
    {
        pTxNode = &Adapter->TxNode;
        
        NdisQueryPacket( 
            Packet,
            NULL,
            &BufferCount,
            &pBuffer,
            &TotalPacketLength );

      if (!pBuffer || !BufferCount || !TotalPacketLength)
      {
        return NDIS_STATUS_FAILURE;
        
      }

       NdisQueryBuffer(pBuffer, &pVirtualAddr, &Length);
       pHeader = (PUCHAR)pVirtualAddr;


        if ( (pHeader[12] == 0x88) && (pHeader[13] == 0x8E)&& (pHeader[14] == 0x01) &&(pHeader[15] == 0x01) )
        {
            DBGPRINT(DBG_TX|DBG_HELP,(L"Temporary don't send EAPOL-start!!EncryptionStatus=0x%x, (0x%x, 0x%x, 0x%x, 0x%x)\n",
                                  Adapter->EncryptionStatus, 
			             pHeader[12],
                                  pHeader[13],
                                  pHeader[14],
                                  pHeader[15]));
            return NDIS_STATUS_SUCCESS;
        }
 	}
}
        
        EnterCriticalSection(&Adapter->TxCriticalSection);

        if(Adapter->TxPacketCount >= (MAX_TX_PACKETS-1) )
        {   
             UCHAR sts;    
             //DBGPRINT(DBG_ERROR,(L"Tx queue is still full (count=%d), return FAILURE for this packet\r\n",Adapter->TxPacketCount));

             sts = TxPacketEnQueue(Adapter, Packet);

             if( sts == TRUE ) //101607 
             {
                 Adapter->TxPacketCount++;  
                 LeaveCriticalSection(&Adapter->TxCriticalSection);   
                 return NDIS_STATUS_SUCCESS;    
             }
             else if ( sts == EQ_REPLACE_QUEUE )
             { 
                 LeaveCriticalSection(&Adapter->TxCriticalSection); 
                 DBGPRINT(DBG_ERROR,(L"Replace a queued packet:%d\n\r",Adapter->TxPacketCount));
                 return NDIS_STATUS_SUCCESS;    
             }  
             else
             {  
                 LeaveCriticalSection(&Adapter->TxCriticalSection); 
                 //NdisMSleep(2000);   
                 DBGPRINT(DBG_ERROR,(L"Throw out current packet:%d\n\r",Adapter->TxPacketCount));  
                 //return success otherwise the endpoint may retransmit this packet that low down the throughput.
                 return NDIS_STATUS_SUCCESS;    
             }
        } 
                                   
        //record how many tx pkt is sent.   
        Adapter->TxPacketSend++;  
    
        DBGPRINT(DBG_TX|DBG_HELP,(L"[Marvell:MrvDrvSend] Adapter->TxPacketSend=%d\n", Adapter->TxPacketSend));    


        if ( TxPacketEnQueue(Adapter, Packet) != TRUE)
        {
            LeaveCriticalSection(&Adapter->TxCriticalSection);
            return NDIS_STATUS_SUCCESS;
        }
        
        Adapter->TxPacketCount++; 

        LeaveCriticalSection(&Adapter->TxCriticalSection);

        if ( Adapter->SentPacket == NULL && Adapter->TxLock == 0 )
        {
            // Fire TxThread!
            Adapter->SoftIntStatus |= MRVL_SOFT_INT_TxRequest;
            SetEvent(Adapter->hControllerInterruptEvent);
        }

        return NDIS_STATUS_SUCCESS;
        

    return Status;
} 
开发者ID:HITEG,项目名称:TenByTen6410_SLC,代码行数:101,代码来源:txproc.c

示例8: Transporter

DWORD WINAPI Transporter(LPVOID lpParam) {
	
	//create message queue and signalize
	MSG msg;
	PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
	
	if (!SetEvent(ghTransporterQueueEvent)) {
		return (EXIT_FAILURE);
	}
	
	//waiting until store thread create message queue
	WaitForSingleObject(ghStoreQueueEvent, INFINITE);
	
	//waiting until power block threads create message queues
	WaitForMultipleObjects(nBlocks, ghPowerBlockQueueEvent, TRUE, INFINITE);
	
	//message loop
	BOOL bRetFI, bRetPB;
	int fuelWeight;
	int emptyBlock;
	
	while (TRUE) {
		
		//check terminate flag
		if (terminate) {
			break;
		}
		
		//initial transport position
		setfillstyle(1, cGREY);
		bar(30, 260, 50, 280);
		
		//post the message to store that transporter is waiting the load
		if (PostThreadMessage(
								dwThreadStoreId,			//thread id destination
								WM_TRANSPORT_EMPTY, 		//message type
								0, 							//no parameters
								0
								)
		== 0) {
			//handle error
			return (EXIT_FAILURE);
		}
		
		//waiting for the store fuel item
		if ((bRetFI = GetMessage(
								&msg,					//pointer to MSG structure
								NULL, 					//retrive messages from any windows belong this thread
								WM_FUEL_LOADING, 		//message filtering
								WM_FUEL_LOADING
								))
		== 0) {
			//WM_QUIT arrived
			//terminate the thread
			break;
		}
		else if (bRetFI == -1) {
			//handle error
			return (EXIT_FAILURE);
		}
		else {
		
			//visualisation of loading state
			setfillstyle(1, cGREEN);
			bar(30, 260, 50, 280);
			//get fuel weight value
			fuelWeight = (int)msg.lParam;
			
			//waiting for the first empty power block
			if ((bRetPB = GetMessage(
									&msg,					//pointer to MSG structure
									NULL, 					//retrive messages from any windows belong this thread
									WM_POWER_BLOCK_EMPTY, 	//message filtering
									WM_POWER_BLOCK_EMPTY
									))
			== 0) {
				//WM_QUIT arrived
				//terminate the thread
				break;
			}
			else if (bRetPB == -1) {
				//handle error
				return (EXIT_FAILURE);
			}
			else {
				//get number of empty power block
				emptyBlock = (int)msg.lParam;
			}
		}
		
		//visualisation of transferring fuel to appropriate power block
		for (int i = 0; i < emptyBlock * 80 + 80; ++i) {
			setfillstyle(1, cGREEN);
			bar(i + 30, 260, i + 50, 280);
			delay(SUSPEND_FACT / 50);
			setfillstyle(1, cWHITE);
			bar(i + 30, 260, i + 50, 280);
		}
		
		//unload transport position
//.........这里部分代码省略.........
开发者ID:bezkalitnikov,项目名称:RTOS_lw_2,代码行数:101,代码来源:powerstation1.cpp

示例9: PowerBlock

DWORD WINAPI PowerBlock(LPVOID lpParam) {
	
	//adduction parameter to index value
	int index = *((int *)lpParam);
	
	//create message queue and signalize
	MSG msg;
	PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
	
	if (!SetEvent(ghPowerBlockQueueEvent[index])) {
		return (EXIT_FAILURE);
	}
	
	//waiting until transporter thread create message queue
	WaitForSingleObject(ghTransporterQueueEvent, INFINITE);
	
	//message loop
	BOOL bRet;
	int fuelWeight;
	
	while (TRUE) {
	
		//check terminate flag
		if (terminate) {
			break;
		}
		
		//post the message to transporter that power block is empty
		if (PostThreadMessage(
							dwThreadTransporterId,		//thread id destination
							WM_POWER_BLOCK_EMPTY, 		//message type
							0,
							(LPARAM)index				//number of power block
							)
		== 0) {
			//handle error
			return (EXIT_FAILURE);
		}
		
		//waiting for the transporter
		if ((bRet = GetMessage(
								&msg,					//pointer to MSG structure
								NULL, 					//retrive messages from any windows belong this thread
								WM_FUEL_ARRIVED, 		//message filtering
								WM_FUEL_ARRIVED
								))
		== 0) {
			//WM_QUIT arrived
			//terminate the thread
			break;
		}
		else if (bRet == -1) {
			//handle error
			return (EXIT_FAILURE);
		}
		else {
			//get fuel weight value
			fuelWeight = (int)msg.lParam;
		}
		
		//visualisation of loading fuel to appropriate power block
		for (int i = 0; i < fuelWeight; ++i) {
			delay(SUSPEND_FACT / 2);
			setfillstyle(1, cGREEN);
			bar(index * 80 + 90, 235 - i * 25, index * 80 + 150, 255 - i * 25);
		}
		
		//post the message that power block is full
		if (PostThreadMessage(
							dwThreadTransporterId,		//thread id destination
							WM_FUEL_UNLOAD, 			//message type
							0, 							
							0							//take the fuel weight
							)
		== 0) {
			//handle error
			return (EXIT_FAILURE);
		}
		
		//visualisation of consumption the fuel
		for (int i = maxLoad - fuelWeight; i < maxLoad; ++i) {
			delay(SUSPEND_FACT * 20);
			setfillstyle(1, cWHITE);
			bar(index * 80 + 90, i * 25 + 10, index * 80 + 150, i * 25 + 30);
		}
	}
	
	return (EXIT_SUCCESS);
}
开发者ID:bezkalitnikov,项目名称:RTOS_lw_2,代码行数:89,代码来源:powerstation1.cpp

示例10: BadConnection

DWORD WINAPI BadConnection(LPVOID Param)
{
	MSG msg;
	HWND hBadConnect;
	HACCOUNT ActualAccount;
	struct BadConnectionParam MyParam;
	NOTIFYICONDATA nid;
	char *NotIconText = Translate(" - connection error"), *src;
	TCHAR *dest;
	int i;

	MyParam=*(struct BadConnectionParam *)Param;
	ActualAccount=MyParam.account;
#ifdef DEBUG_SYNCHRO
	DebugLog(SynchroFile,"BadConnect:Incrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
#endif
	SCIncFcn(ActualAccount->UsingThreads);

//	we will not use params in stack anymore
	SetEvent(MyParam.ThreadRunningEV);

	__try
	{
		hBadConnect=CreateDialogParam(YAMNVar.hInst,MAKEINTRESOURCE(IDD_DLGBADCONNECT),NULL,DlgProcYAMNBadConnection,(LPARAM)&MyParam);
		SendMessage(hBadConnect,WM_SETICON,ICON_BIG,(LPARAM)g_LoadIconEx(3));
		SendMessage(hBadConnect,WM_SETICON,ICON_SMALL,(LPARAM)g_LoadIconEx(3));

		memset(&nid, 0, sizeof(nid));
		nid.cbSize=sizeof(NOTIFYICONDATA);
		nid.hWnd=hBadConnect;
		nid.hIcon=g_LoadIconEx(3);
		nid.uID=0;
		nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
		nid.uCallbackMessage=WM_YAMN_NOTIFYICON;

#ifdef DEBUG_SYNCHRO
		DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait\n");
#endif
		if (WAIT_OBJECT_0 != WaitToReadFcn(ActualAccount->AccountAccessSO))
		{
#ifdef DEBUG_SYNCHRO
			DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read wait failed\n");
#endif
			return 0;
		}
#ifdef DEBUG_SYNCHRO
		DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read enter\n");
#endif
		for (src=ActualAccount->Name,dest=nid.szTip,i=0;(*src != (TCHAR)0) && (i+1<sizeof(nid.szTip));*dest++=*src++);
		for (src=NotIconText;(*src != (TCHAR)0) && (i+1<sizeof(nid.szTip));*dest++=*src++);
		*dest=(TCHAR)0;

		if (ActualAccount->BadConnectN.Flags & YAMN_ACC_SND)
			CallService(MS_SKIN_PLAYSOUND,0,(LPARAM)YAMN_CONNECTFAILSOUND);
		if (ActualAccount->BadConnectN.Flags & YAMN_ACC_MSG)
			ShowWindow(hBadConnect,SW_SHOWNORMAL);
		if (ActualAccount->BadConnectN.Flags & YAMN_ACC_ICO)
			Shell_NotifyIcon(NIM_ADD,&nid);
#ifdef DEBUG_SYNCHRO
		DebugLog(SynchroFile,"BadConnect:ActualAccountSO-read done\n");
#endif
		ReadDoneFcn(ActualAccount->AccountAccessSO);

		UpdateWindow(hBadConnect);
		while(GetMessage(&msg,NULL,0,0))
		{
			TranslateMessage(&msg); 
			DispatchMessage(&msg);  
		}

//	now, write to file. Why? Because we want to write when was new mail last checked
		if ((ActualAccount->Plugin->Fcn != NULL) && (ActualAccount->Plugin->Fcn->WriteAccountsFcnPtr != NULL) && ActualAccount->AbleToWork)
			ActualAccount->Plugin->Fcn->WriteAccountsFcnPtr();
	}
	__finally
	{
#ifdef DEBUG_SYNCHRO
		DebugLog(SynchroFile,"BadConnect:Decrementing \"using threads\" %x (account %x)\n",ActualAccount->UsingThreads,ActualAccount);
#endif
		SCDecFcn(ActualAccount->UsingThreads);
	}
	return 0;
}
开发者ID:martok,项目名称:miranda-ng,代码行数:83,代码来源:badconnect.cpp

示例11: Store

DWORD WINAPI Store(LPVOID lpParam) {
	
	//initialize the pseudorandom numbers generator
	unsigned int seed;
	seed = (unsigned int)time(NULL);
	srand(seed);
	
	//create message queue and signalize
	MSG msg;
	PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
	
	if (!SetEvent(ghStoreQueueEvent)) {
		return (EXIT_FAILURE);
	}
	
	//waiting until transporter thread create message queue
	WaitForSingleObject(ghTransporterQueueEvent, INFINITE);
	
	//message loop
	BOOL bRet;
	int fuelWeight;
	
	while (TRUE) {
		
		//check terminate flag
		if (terminate) {
			break;
		}
		
		//calculate fuel weight
		//it has mass range from 1 to maxLoad
		fuelWeight = rand() % maxLoad + 1;
		
		//visualisation of production of the fuel
		for (int i = 0; i < fuelWeight; ++i) {
			delay(SUSPEND_FACT * 2);
			setfillstyle(1, cGREY);
			bar(10, 235 - i * 25, 70, 255 - i * 25);
		}
		
		//wait the transporter
		if ((bRet = GetMessage(&msg,				//pointer to MSG structure
							NULL, 					//retrive messages from any windows belong this thread
							WM_TRANSPORT_EMPTY, 	//message filtering
							WM_TRANSPORT_EMPTY)) 
		== 0) {
			//WM_QUIT arrived
			//terminate the thread
			break;
		}
		else if (bRet == -1) {
			//handle error
			return (EXIT_FAILURE);
		}
		else {
			//load the fuel to the transporter
			//visualisation of load process
			for (int i = maxLoad - fuelWeight; i < maxLoad; ++i) {
				delay(SUSPEND_FACT / 2);
				setfillstyle(1, cWHITE);
				bar(10, i * 25 + 10, 70, i * 25 + 30);
			}
			//post the message
			if (PostThreadMessage(dwThreadTransporterId, 	//message for transporter thread
							WM_FUEL_LOADING, 				//message type
							0,								//no WPARAM
							(LPARAM)fuelWeight) 			//pass fuel weight as LPARAM
			== 0) {
				//handle error
				return (EXIT_FAILURE);
			}
		}
	}
	return (EXIT_SUCCESS);
}
开发者ID:bezkalitnikov,项目名称:RTOS_lw_2,代码行数:75,代码来源:powerstation1.cpp

示例12: BaseRendererImpl_Receive

HRESULT WINAPI BaseRendererImpl_Receive(BaseRenderer *This, IMediaSample * pSample)
{
    HRESULT hr = S_OK;
    REFERENCE_TIME start, stop;
    AM_MEDIA_TYPE *pmt;

    TRACE("(%p)->%p\n", This, pSample);

    if (This->pInputPin->end_of_stream || This->pInputPin->flushing)
        return S_FALSE;

    if (This->filter.state == State_Stopped)
        return VFW_E_WRONG_STATE;

    if (IMediaSample_GetMediaType(pSample, &pmt) == S_OK)
    {
        if (FAILED(This->pFuncsTable->pfnCheckMediaType(This, pmt)))
        {
            return VFW_E_TYPE_NOT_ACCEPTED;
        }
    }

    This->pMediaSample = pSample;
    IMediaSample_AddRef(pSample);

    if (This->pFuncsTable->pfnPrepareReceive)
        hr = This->pFuncsTable->pfnPrepareReceive(This, pSample);
    if (FAILED(hr))
    {
        if (hr == VFW_E_SAMPLE_REJECTED)
            return S_OK;
        else
            return hr;
    }

    if (This->pFuncsTable->pfnPrepareRender)
        This->pFuncsTable->pfnPrepareRender(This);

    EnterCriticalSection(&This->csRenderLock);
    if ( This->filter.state == State_Paused )
    {
        if (This->pFuncsTable->pfnOnReceiveFirstSample)
            This->pFuncsTable->pfnOnReceiveFirstSample(This, pSample);

        SetEvent(This->evComplete);
    }

    /* Wait for render Time */
    if (SUCCEEDED(IMediaSample_GetTime(pSample, &start, &stop)))
    {
        hr = S_FALSE;
        RendererPosPassThru_RegisterMediaTime(This->pPosition, start);
        if (This->pFuncsTable->pfnShouldDrawSampleNow)
            hr = This->pFuncsTable->pfnShouldDrawSampleNow(This, pSample, &start, &stop);

        if (hr == S_OK)
            ;/* Do not wait: drop through */
        else if (hr == S_FALSE)
        {
            if (This->pFuncsTable->pfnOnWaitStart)
                This->pFuncsTable->pfnOnWaitStart(This);

            LeaveCriticalSection(&This->csRenderLock);
            hr = QualityControlRender_WaitFor(This->qcimpl, pSample, This->RenderEvent);
            EnterCriticalSection(&This->csRenderLock);

            if (This->pFuncsTable->pfnOnWaitEnd)
                This->pFuncsTable->pfnOnWaitEnd(This);
        }
        else
        {
            LeaveCriticalSection(&This->csRenderLock);
            /* Drop Sample */
            return S_OK;
        }
    }

    if (SUCCEEDED(hr))
    {
        QualityControlRender_BeginRender(This->qcimpl);
        hr = This->pFuncsTable->pfnDoRenderSample(This, pSample);
        QualityControlRender_EndRender(This->qcimpl);
    }

    QualityControlRender_DoQOS(This->qcimpl);

    BaseRendererImpl_ClearPendingSample(This);
    LeaveCriticalSection(&This->csRenderLock);

    return hr;
}
开发者ID:AlexSteel,项目名称:wine,代码行数:91,代码来源:renderer.c

示例13: directsound_stream_init


//.........这里部分代码省略.........
  wfx.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;

  switch (stream_params.format) {
  case CUBEB_SAMPLE_S16LE:
    wfx.Format.wBitsPerSample = 16;
    wfx.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
    break;
  case CUBEB_SAMPLE_FLOAT32LE:
    wfx.Format.wBitsPerSample = 32;
    wfx.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
    break;
  default:
    return CUBEB_ERROR_INVALID_FORMAT;
  }

  wfx.Format.nBlockAlign = (wfx.Format.wBitsPerSample * wfx.Format.nChannels) / 8;
  wfx.Format.nAvgBytesPerSec = wfx.Format.nSamplesPerSec * wfx.Format.nBlockAlign;
  wfx.Samples.wValidBitsPerSample = wfx.Format.wBitsPerSample;

  if (FAILED(primary->SetFormat((LPWAVEFORMATEX) &wfx))) {
    /* XXX free primary */
    return CUBEB_ERROR;
  }

  primary->Release();

  cubeb_stream * stm = (cubeb_stream *) calloc(1, sizeof(*stm));
  assert(stm);

  stm->context = context;

  stm->params = stream_params;

  stm->data_callback = data_callback;
  stm->state_callback = state_callback;
  stm->user_ptr = user_ptr;

  InitializeCriticalSection(&stm->lock);

  /*
    create secondary buffer
  */
  bd.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPOSITIONNOTIFY;
  bd.dwBufferBytes = (DWORD) (wfx.Format.nSamplesPerSec / 1000.0 * latency * bytes_per_frame(stream_params));
  if (bd.dwBufferBytes % bytes_per_frame(stream_params) != 0) {
    bd.dwBufferBytes += bytes_per_frame(stream_params) - (bd.dwBufferBytes % bytes_per_frame(stream_params));
  }
  bd.lpwfxFormat = (LPWAVEFORMATEX) &wfx;
  if (FAILED(context->dsound->CreateSoundBuffer(&bd, &stm->buffer, NULL))) {
    return CUBEB_ERROR;
  }

  stm->buffer_size = bd.dwBufferBytes;

  LPDIRECTSOUNDNOTIFY notify;
  if (stm->buffer->QueryInterface(IID_IDirectSoundNotify, (LPVOID *) &notify) != DS_OK) {
    /* XXX free resources */
    return CUBEB_ERROR;
  }

  DSBPOSITIONNOTIFY note[3];
  for (int i = 0; i < 3; ++i) {
    note[i].dwOffset = (stm->buffer_size / 4) * i;
    note[i].hEventNotify = context->streams_event;
  }
  if (notify->SetNotificationPositions(3, note) != DS_OK) {
    /* XXX free resources */
    return CUBEB_ERROR;
  }

  notify->Release();

  refill_stream(stm, 1);
  /* XXX remove this, just a test that double refill does not overwrite existing data */
  refill_stream(stm, 0);
  uint64_t pos;
  cubeb_stream_get_position(stm, &pos);

  stm->node = (struct cubeb_list_node *) calloc(1, sizeof(*node));
  stm->node->stream = stm;

  EnterCriticalSection(&context->lock);
  if (!context->streams) {
    context->streams = stm->node;
  } else {
    node = context->streams;
    while (node->next) {
      node = node->next;
    }
    node->next = stm->node;
    stm->node->prev = node;
  }
  LeaveCriticalSection(&context->lock);

  SetEvent(context->streams_event);

  *stream = stm;

  return CUBEB_OK;
}
开发者ID:jussi-kalliokoski,项目名称:cubeb,代码行数:101,代码来源:cubeb_directsound.cpp

示例14: PeekMessage

DWORD Scheduler::SchedulerThreadProcPrivate()
{
    HRESULT hr = S_OK;
    MSG     msg;
    LONG    lWait = INFINITE;
    BOOL    bExitThread = FALSE;

    // Force the system to create a message queue for this thread.
    // (See MSDN documentation for PostThreadMessage.)
    PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);

    // Signal to the scheduler that the thread is ready.
    SetEvent(m_hThreadReadyEvent);

    while( !bExitThread )
    {
        // Wait for a thread message OR until the wait time expires.
        DWORD dwResult = MsgWaitForMultipleObjects(0, NULL, FALSE, lWait, QS_POSTMESSAGE);

        if (dwResult == WAIT_TIMEOUT)
        {
            // If we timed out, then process the samples in the queue
            hr = ProcessSamplesInQueue(&lWait);
            if (FAILED(hr))
            {
                bExitThread = TRUE;
            }
        }

        while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
            BOOL bProcessSamples = TRUE;

            switch (msg.message)
            {
            case eTerminate:
                bExitThread = TRUE;
                break;

            case eFlush:
                // Flushing: Clear the sample queue and set the event.
                m_ScheduledSamples.Clear();
                lWait = INFINITE;
                SetEvent(m_hFlushEvent);
                break;

            case eSchedule:
                // Process as many samples as we can.
                if (bProcessSamples)
                {
                    hr = ProcessSamplesInQueue(&lWait);
                    if (FAILED(hr))
                    {
                        bExitThread = TRUE;
                    }
                    bProcessSamples = (lWait != INFINITE);
                }
                break;
            } // switch

        } // while PeekMessage

    }  // while (!bExitThread)

    return (SUCCEEDED(hr) ? 0 : 1);
}
开发者ID:Jarvizx,项目名称:webrtc4all,代码行数:66,代码来源:scheduler.cpp

示例15: __serial_check_fds

static void __serial_check_fds(SERIAL_DEVICE* serial)
{
	IRP* irp;
	IRP* prev;
	SERIAL_TTY* tty;
	UINT32 result = 0;
	BOOL irp_completed = FALSE;

	ZeroMemory(&serial->tv, sizeof(struct timeval));
	tty = serial->tty;

	/* scan every pending */
	irp = list_peek(serial->pending_irps);

	while (irp)
	{
		DEBUG_SVC("MajorFunction %u", irp->MajorFunction);

		switch (irp->MajorFunction)
		{
			case IRP_MJ_READ:
				if (FD_ISSET(tty->fd, &serial->read_fds))
				{
					irp->IoStatus = STATUS_SUCCESS;
					serial_process_irp_read(serial, irp);
					irp_completed = TRUE;
				}
				break;

			case IRP_MJ_WRITE:
				if (FD_ISSET(tty->fd, &serial->write_fds))
				{
					irp->IoStatus = STATUS_SUCCESS;
					serial_process_irp_write(serial, irp);
					irp_completed = TRUE;
				}
				break;

			case IRP_MJ_DEVICE_CONTROL:
				if (serial_tty_get_event(tty, &result))
				{
					DEBUG_SVC("got event result %u", result);

					irp->IoStatus = STATUS_SUCCESS;
					stream_write_UINT32(irp->output, result);
					irp->Complete(irp);
					irp_completed = TRUE;
				}
				break;

			default:
				DEBUG_SVC("no request found");
				break;
		}

		prev = irp;
		irp = (IRP*) list_next(serial->pending_irps, irp);

		if (irp_completed || (prev->IoStatus == STATUS_SUCCESS))
		{
			list_remove(serial->pending_irps, prev);
			SetEvent(serial->in_event);
		}
	}
}
开发者ID:KimDongChun,项目名称:FreeRDP,代码行数:65,代码来源:serial_main.c


注:本文中的SetEvent函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。