In my program i have a window which the user sees when its time to swipe a credit card. The window will wait until the credit card is swiped or any other error happens. Currently, the wait window is creating card reader class internally and using delegates/callback methods of the card reader class to know when the data on the card is available or any other errors happens.
Since there are 4-5 type of readers available i am implementing strategy pattern for the CardReader.
I would also like to decouple the CardReader creation/insstantiation code from the window code. Can you please give tips for doing the same.
I will be reading your comments prior to designing the strategy pattern class for CardReader.
Thanks
Make the waiting window constructor require a reference to the class of the reader, register the waiting window for a OnCardReadEvent. When the event is received invoke the function inside the reader class to check it, than if needed continue displaying the waiting window or close it. On window close unregister from the OnCardReadEvent
If you don’t have a OnCardReadEvent then make one.
Inside the reader class when the read is done make something like this to enable multiple windows to receive data from a single reader
You haven’t gave us much to work with 🙂