flat assembler
Message board for the users of flat assembler.
  
|  Index
      > Windows > Is there a better way to wait for fasm to finish? | 
| Author | 
 | 
| revolution 04 May 2013, 09:34 Doing what? | |||
|  04 May 2013, 09:34 | 
 | 
| tthsqe 04 May 2013, 09:37 oh, I though it was clear from the code.
 I am calling fasm from a 64 bit program and waiting for it to finish before opening the output file. Obviously, problems arise if fasm takes more than 0.3 seconds to compile... | |||
|  04 May 2013, 09:37 | 
 | 
| revolution 04 May 2013, 09:42 Sure there are much better ways. Probably not using the ShellExecute and instead use CreateProcess would be a start. That way you can wait on the handle and also get the exit code. | |||
|  04 May 2013, 09:42 | 
 | 
| nmaps 05 May 2013, 20:26 Create a job or semaphore and have your process loop to check if it's finished (or WaitForObject). | |||
|  05 May 2013, 20:26 | 
 | 
| typedef 07 May 2013, 04:24 Use CreateProcess and watch it. Since you have control over it.   | |||
|  07 May 2013, 04:24 | 
 | 
| tthsqe 07 May 2013, 08:15 Thanks - I'm going to try CreateProcess.   | |||
|  07 May 2013, 08:15 | 
 | 
| edfed 07 May 2013, 08:17 or maybe read the binary file attributes to see if it's date is not older than N seconds. lol
 if CreateProcess can return fasm state, it should be the solution. | |||
|  07 May 2013, 08:17 | 
 | 
| Feryno 07 May 2013, 09:20 do it as revolution suggested
 use the handle returned by CreateProcess and then you can call GetExitCodeProcess http://msdn.microsoft.com/library/windows/desktop/ms683189%28v=vs.85%29.aspx if the return value is STILL_ACTIVE you must call it later again - e.g. some timeout (as the posted Sleep) or NtYieldExecution (exported from ntdll.dll) | |||
|  07 May 2013, 09:20 | 
 | 
| AsmGuru62 07 May 2013, 14:59 It is better to use CreateProcess() on separate thread and just WaitForSingleObject() on the handle.
 Otherwise it is a loop on main thread which polls for STILL_ACTIVE and loads the CPU. | |||
|  07 May 2013, 14:59 | 
 | 
| typedef 07 May 2013, 23:28 AsmGuru62 wrote: It is better to use CreateProcess() on separate thread and just WaitForSingleObject() on the handle. CreateEvent() / ResetEvent/ RaiseEvent on a separate thread would accomplish this. Besides, WaitForSingleObject is a blocking API  | |||
|  07 May 2013, 23:28 | 
 | 
| < Last Thread | Next Thread > | 
| Forum Rules: 
 | 
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.