état d'une tâche

hrp Messages postés 24 Date d'inscription mardi 18 janvier 2005 Statut Membre Dernière intervention 17 juin 2006 - 7 févr. 2005 à 20:42
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019 - 8 févr. 2005 à 20:52
Hello,

comment récupérer l'état d'une tâche en cours d'exécution par exemple "En cours d'exécution" ou "sans réponse"?

merci pour votre aide

huw

7 réponses

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
7 févr. 2005 à 22:23
Si le prog a une fenêtre, tu peux tester avec SendMessageTimeout().
Sinon ben faudra y réfléchir.

ciao...
BruNews, MVP VC++
0
hrp Messages postés 24 Date d'inscription mardi 18 janvier 2005 Statut Membre Dernière intervention 17 juin 2006
8 févr. 2005 à 10:03
ok, j'ai regarder dans la sdk windows ce que fait cette fonciton:
---------------------------------
The SendMessageTimeout function sends the specified message to a window or windows. The function calls the window procedure for the specified window and, if the specified window belongs to a different thread, does not return until the window procedure has processed the message or the specified time-out period has elapsed. If the window receiving the message belongs to the same queue as the current thread, the window procedure is called directly - the time-out value is ignored.


LRESULT SendMessageTimeout(


HWND hWnd, // handle of destination window
UINT Msg, // message to send
WPARAM wParam, // first message parameter
LPARAM lParam, // second message parameter
UINT fuFlags, // how to send the message
UINT uTimeout, // time-out duration
LPDWORD lpdwResult // return value for synchronous call
);



Parameters


hWnd


Identifies the window whose window procedure will receive the message. If this parameter is HWND_TOPMOST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows.


Msg


Specifies the message to be sent.


wParam


Specifies additional message-specific information.


lParam


Specifies additional message-specific information.


fuFlags


Specifies how to send the message. This parameter can be a combination of the following values:


Value Meaning
SMTO_ABORTIFHUNG Returns without waiting for the time-out period to elapse if the receiving process appears to be in a "hung" state.
SMTO_BLOCK Prevents the calling thread from processing any other requests until the function returns.
SMTO_NORMAL The calling thread is not prevented from processing other requests while waiting for the function to return.



uTimeout


Specifies the duration, in milliseconds, of the time-out period.


lpdwResult


Specifies the result of the message processing and depends on the message sent.





Return Values


If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE. To get extended error information, call GetLastError.
--------------------------------------
mon but, c'est de savoir si ma fenêtre internet explorer fonctionne encore ("en cours d'exécution") ou si son proccessus est bloqué ("sans réponse"). pour réaliser cela que dois-je passer en argument à la fonction "SendMessageTimeout", notement les arguments:
-UINT Msg
-WPARAM wParam
-LPARAM lParam

merci.

huw
0
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
8 févr. 2005 à 13:00
Tu envoies nimporte quoi du moment que ça ne provoque pas une cata, fais quelques tests, du genre:
DWORD r;
if(!SendMessageTimeout(hwnd,WM_COMMAND,12, 0,SMTO_ABORTIFHUNG,1000,&r) {
if(!GetLastError()) ProgEstBloque;
}

WM_COMMAND,12,0
sont totalement arbitraires, teste ce qui va bon dans ton cas.

ciao...
BruNews, MVP VC++
0
hrp Messages postés 24 Date d'inscription mardi 18 janvier 2005 Statut Membre Dernière intervention 17 juin 2006
8 févr. 2005 à 13:30
j'ai essayé simplement comme ça et ça semble aussi fonctionner:

DWORD r;

if(!SendMessageTimeout(hwnd,NULL,NULL, NULL,SMTO_ABORTIFHUNG,5000,&r) {
//Prog est bloqué

}

merci pour ton aide.

huw
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
8 févr. 2005 à 13:38
Que ça semble n'est pas toujours suffisant, vérifie toujours que GetLastError() retourne bien zéro pour être sur du blocage.

ciao...
BruNews, MVP VC++
0
ShareVB Messages postés 2676 Date d'inscription vendredi 28 juin 2002 Statut Membre Dernière intervention 13 janvier 2016 26
8 févr. 2005 à 20:34
salut,

le guideline de Microsoft tend à dire : un timeout de 5 secondes et le message WM_NULL envoyé (avec SendMessageTimeout)...mais il y a un problème (je ne sais pas avec du C mais je l'ai rencontré avec VB)...

Si l'application ne répond pas, SendMessageTimeout ne renvoie la main que dans 5 secondes pendant lesquelles le thread qui a appelé SendMessageTimeout ne répond pas...et si c'est celui d'une fenêtre, c'est embettant...

il existe les fonctions IsHungAppWindow (pour NT/2K:XP) et IsHungThread (pour 9x) qui rendent (en principe) immédiatement la main même en cas de "hung"...

http://upc.pkmn.co.uk/win32/nonresp.shtml

ShareVB
0
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
8 févr. 2005 à 20:52
Cette fonction fait bien son boulot actuellement mais MSDN est sans ambiguité sur son avenir:
It is recommended that you do not use it in new programs because it might be altered or unavailable in subsequent versions of Windows.

ciao...
BruNews, MVP VC++
0
Rejoignez-nous