views:

26

answers:

0

I need some feedback on a threading problem that I am trying to solve.

The problem (this is coded as a winform application in C#) I am comparing to lists which should be identical - if there is a discrepancy I popup a window and get the user to resolve the discrepancy by indicating which items are new and which items were deleted. The issue is as the list are being compared or the popup window is displayed to resolve any discrepancies one of the list can be changing (multi-threaded application). When the list changes the popup window should save all the changes made so far and close – at that point the process starts from the beginning again.

Proposed Solution Run the code that compares the two lists and the popup window to resolve any discrepancies on a separate thread (Lets call this threadA)(I know that I am launching another UI element on a different thread).

When an event comes in that the list has changed (Another thread (Lets call this threadB)– this is not the main thread). ThreadB signals ThreadA to save all changes the user has made so far – this is done by threadB raising an event to save all the data in the popup window, than ThreadB aborts ThreadA this is the part I am not feeling to hot about. I think it would be cleaner if ThreadB could somehow signal ThreadA to save the data and close the window, except I can not think of a solution that does not involve polling.

Any feedback, ideas would be greatly appreciated.