I use C ++ / cli (should also apply to C #) and create a winforms program.
I have some lines of code that edit data in a DataGridView. The code is executed by the FileSystemWatcher event, but can be executed by a background worker or a simple thread. However, it is NOT executed by the user interface thread.
DGV is placed on the TabControl tab. When the code is executed, when the tab containing the DGV has focus, the code crashes with a well-known and expected exception. "Crossflow operation is invalid."
But when the other tab has focus, the code runs smoothly. I assume that DGV is not updated when it is not displayed, which leads to the fact that the code will work in this case. But this means that sending messages, such as WM_PAINT, to the message queue depends on the visibility (shown or not) of the DGV, and if it is not visible, these messages should be sent when the DGV is displayed again.
It is right?
What are the differences in code output when DGV is displayed (not)?
source
share