urugedoc101122
September 3rd, 2009, 06:50 AM
Hi,
I've been assigned a project to be implemented in C#. Here's a little overview on the system:
The application will have 2 threads:
1. Main thread - handles the main application - GUI, file handling etc...
2. Monitor Thread - frequently checks/polls on the status of a USB port.
The premise is a USB thumb drive needs to be connected ALWAYS in order for the main application to run. If the thumb drive was removed, the main application will stop any processing, lock itself and show a prompt saying to re-insert the USB drive.
My idea is that the monitor thread will have one property boolean IsUSBPresent. whenever this changes value, it will send an event or signal to the main thread. The main thread will then perform the appropriate action in handling the event.
My problem now is I dont have any idea how to implement it. Is there a way for the main thread to "listen" to that property - something like an OnIsUSBPresentChanged event...
I've been browsing and complex things come up like delegates, custom events etc...
I'm hoping someone can point me to an article or a tutorial
Any help would be appreciated. Thanks a bunch!. ^_^
I've been assigned a project to be implemented in C#. Here's a little overview on the system:
The application will have 2 threads:
1. Main thread - handles the main application - GUI, file handling etc...
2. Monitor Thread - frequently checks/polls on the status of a USB port.
The premise is a USB thumb drive needs to be connected ALWAYS in order for the main application to run. If the thumb drive was removed, the main application will stop any processing, lock itself and show a prompt saying to re-insert the USB drive.
My idea is that the monitor thread will have one property boolean IsUSBPresent. whenever this changes value, it will send an event or signal to the main thread. The main thread will then perform the appropriate action in handling the event.
My problem now is I dont have any idea how to implement it. Is there a way for the main thread to "listen" to that property - something like an OnIsUSBPresentChanged event...
I've been browsing and complex things come up like delegates, custom events etc...
I'm hoping someone can point me to an article or a tutorial
Any help would be appreciated. Thanks a bunch!. ^_^