question

HienPham-0040 avatar image
0 Votes"
HienPham-0040 asked HienPham-0040 edited

InitializeCriticalSection

Hello everyone

I have a question about InitializeCriticalSection.

Thank you for your support!

windows-api
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered Viorel-1 edited

In my opinion, the next approach should work:

  1. When start program
     • Create file
     • InitializeCriticalSection

  2. Write file
     • EnterCriticalSection
     • Write file
     • If file > 2M then create new file
     • LeaveCriticalSection

  3. Create new file
     • Close current file
     • Create new file, make it current file

  4. End program
     • Close current file
     • DeleteCriticalSection

or an alternative:

  1. When start program
     • InitializeCriticalSection

  2. Write file
     • EnterCriticalSection
     • If file not created then create file
     • Else If file > 2M then create new file
     • Write file
     • LeaveCriticalSection

  3. Create new file
     • Close current file
     • Create new file, make it current file

  4. End program
     • If file created then close file
     • DeleteCriticalSection

You must also finish the threads before executing 4.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.