The Parallel.NET component provides you with a robust and straightforward way of getting your .NET applications to perform regular tasks at configurable intervals. There is no interference to other aspects of the application including the UI or users.
Check out Web Miner, a real world web content mining application which takes advantage of Parallel.NET. See an application preview here while paying close attention to the CPU usage, memory usage and mining duration to see Parallet.NET in action.
What are the features?
- Execute tasks at configurable intervals
- Run multiple tasks at different intervals using 1 ParallelScheduler
- Configure whether background tasks use the ThreadPool or create their own thread
- Specify whether the task should run infinitely or for a limited number of times
- Add observers for any background task having the observers alerted each time the task completes
- Allow the observers to manipulate the output from the task that completed
- Specify how the observers will be executed by the ParallelScheduler – Sequentially or Concurrently
- Configurable exception handling just in case a task does not handle its own exceptions
When would I use this?
- Loading news feeds
- Clean-up operations
- Sending emails without reducing the responsiveness of the UI
- Monitoring internal and external resources
- Updating devices or other services with new information
- Refresh your data sources from external/internal web services
- Monitor database tables for changes or new information
- Monitor inboxes for new emails
- Process video, images, and other multimedia files
- Send large files
- Uploading multiple files (FTP, etc.)
Tasks that take a long time to complete including jobs that are processor intensive, hard disk intensive or task that access external resources such as Web services, databases (in some cases), news feeds, etc. are ideal candidates to be run in the background. Once these tasks are completed the observers will be notified, and then they can perform their work which can include updating the UI, notifying users of changes & updates, etc.
This component is built using the .NET 2.0 Framework which means it can be used in all .NET applications that are using the 2.0 framework or higher. This component can be used in all types of .NET applications including:
- Windows Forms
- ASP.NET WebForms
- ASP.NET MVC
- Windows Services
- Web Services (XML/WCF)
Is it reliable?
The component also ensures that many pitfalls are not encountered including:
- No Deadlocks
- No Memory leaks – clean up through the dispose method & consider problems such as the lapsed listener
- No Exceptions leaks – Exception handling to ensure undesired termination of the application does not occur
- ASP.NET ThreadPool & Service Unavailable handling – Gives control of whether ThreadPool threads are used (by default no). This ensures that threads are not taken away from high availability ASP.NET applications causing the dreaded “Service Unavailable” message
- Task/Background work structure – Flexible mechanism for creating complex background operations
- Strong name signed – Allows referencing in other application that are strong named signed & also installing into the GAC
- Support custom shutdown during application pool recycling for web applications.
What is in the package?
- .NET 2.0 Assemblies
- Debug files (PDB)
- Xml comments (Intellisense)
- Usage documentation
- API Documentation
- 2 x Console demo application
- ASP.NET MVC demo application
- ASP.NET Webforms demo application
- WinForm demo application
- C# & VB.NET Source Code
- Visual Studio Solution
How would I use this component?
Example of how to use the ParallelScheduler in conjunction with the UrlReaderBackgroundWork to infinitely poll a URL every 5 seconds. The work is scheduled to start immediately using ThreadPool threads with two registered observers that will be executed in Parallel every time the work is done.
01/12/2013 – Added Support for application pool recycling. The work instance can shut itself down properly during an automatic or manual application pool recycling event.
18/12/2013 – Added VB.NET source code.