Each thread should not have its own instance of FileOutputWindow. You should have once instance and use it from all threads. This should work. Multiple instances of the program will probably not be able to write to the same file, which is normal. If a user does not have permission to write to a file, it will obviously not work.
Thanks for the clear reply!
I have one more question, could my wrong usage of the FileOutputWindow lead to crash?
I’m currently debugging a crash issue and the dump shows that it crashes at the destructor of FileOutputWindow. by access violation error. But I’m not able to reproduce it yet.
So I would like to ask your professional opinion qpjon it.
Thank you!
Yes - you need to keep at least one strong reference to it, or it will go out of scope and deallocate itself before you are done with it. I recommend keeping references to it using smart pointers (FileOutputWindow::Pointer) instead of plain pointers.
Thanks!
But I didn’t catch the point.
In each of my thread, when the FileOutputWindow deallocate itself, the thread have finished using the itk functions. So I’m done with it.
Is the problem due to all thread using different FileOutputWindow but output to the same file? Maybe they will share something internally?
I have tested one thread terminates before other thread write other logs, it seems ok.