2,783 questions
In my opinion, the next approach should work:
- When start program
• Create file
• InitializeCriticalSection - Write file
• EnterCriticalSection
• Write file
• If file > 2M then create new file
• LeaveCriticalSection - Create new file
• Close current file
• Create new file, make it current file - End program
• Close current file
• DeleteCriticalSection
or an alternative:
- When start program
• InitializeCriticalSection - Write file
• EnterCriticalSection
• If file not created then create file
• Else If file > 2M then create new file
• Write file
• LeaveCriticalSection - Create new file
• Close current file
• Create new file, make it current file - End program
• If file created then close file
• DeleteCriticalSection
You must also finish the threads before executing 4.