Our software, along with many other business-related actions, retrieves email which it summarizes key elements of in a client data set that the user can interact with in a variety of ways. A shortfall is that the user must still hit a "retrieve mail" button to get the mail since we don't want the main application thread stopped for a few seconds every minute checking to see if there is new mail and then updating the cds if there is any.
This sounds to me like a good candidate for putting the email retrieval in a separate thread, but I've never dealt with threads before, so I'm not sure where to begin or what the pitfalls are. I'd be happy for any foundational guidance on what to do/avoid in setting up the thread correctly, but in particular, would like to know how one handles potential conflicts between what the two threads are doing. e.g., what happens if the email retrieval thread is adding new messages to the cds at the same point that the user is double-clicking some other message in the data grid that is linked to the same cds? Thanks in advance for any help.