Hey,
Im writing a DLL and I want to write some data to a file (150k+)
The problem is - WriteFile is not writing everything it should write
It looks like the thread gets terminated before WriteFile finish its work.
any ideas ? thanks
Hey,
Im writing a DLL and I want to write some data to a file (150k+)
The problem is - WriteFile is not writing everything it should write
It looks like the thread gets terminated before WriteFile finish its work.
any ideas ? thanks
If you exit your process before the thread completes, all other threads will be terminated (from ExitProcess):
Exiting a process causes the following:
- All of the threads in the process, except the calling thread, terminate their execution without receiving a DLL_THREAD_DETACH notification.
- The states of all of the threads terminated in step 1 become signaled.
- The entry-point functions of all loaded dynamic-link libraries (DLLs) are called with DLL_PROCESS_DETACH.
- After all attached DLLs have executed any process termination code, the ExitProcess function terminates the current process, including the calling thread.
- The state of the calling thread becomes signaled.
- All of the object handles opened by the process are closed.
- The termination status of the process changes from STILL_ACTIVE to the exit value of the process.
- The state of the process object becomes signaled, satisfying any threads that had been waiting for the process to terminate.
You will need to explicitly wait for the thread executing WriteFile to complete, usually via WaitForSingleObject(thread handle, ...)
.