Multi-Threading in .NET WinForms
Recently when designing a small task notification application, I ran into a lot of issues with threading. One of the main issues was that I needed a thread to run in the background when the application was in a certain state and and do some work on a regular interval (in this case, every 60 seconds).Here's the scenario: The application could be put into a monitor state, where it will be sent to the computer's system tray. At this point we start up a seperate thread. This thread will start a timer that that has a callback attached to it. Every 60 seconds when the timer fires, this callback method is called.
Within the timer method, we do some required processing to see if there is a task that has been assigned to the current date/time. I also created a delegate that will handle the case in where we find a task in the timer method and act upon it. This delegate is responsible for calling the method that will perform the notification on the current task.
Page 2 of this article demonstrates how to accomplish this in C#.
back
|
next
|
about