Pantelis
Pantelis

Reputation: 2060

Video Player Threading

I'm developing a win forms, continious 24/7 video player and I need some help deciding which Threading class suits my needs. This is my first multithreading attempt. I'm familiar with the BackgroundWorker class, couple of properties to set and events to handle, but I have not delved much deeper to the rest of the Threading classes. I'm considering my application's tasks simple but I might be wrong regarding the level of simplicity.

Here's some of the player's functionality:

Reads an SQL Server database and displays data on a DataGridView.

Adds DataRepeaterItems to a DataRepeater control (serving the purposes of a playlist) from DataGridView CellMouseDoubleClick event.

Loads the video sound on a secondary (preview) player with each CellMouseClick event.

The player's PLAY button loads and plays the video on a video player instance, updates some labels, adds a DataRepeaterItem on a secondary DataRepeater (serves the role of a playlist history) and deletes the current DataRepeaterItem, the one currently playing, from the playlist DataRepeater control.

There are a couple more buttons deleting all DataRepeaterItems and moving the Items up and down the list. Later something like an auto-playlist functionality will be added, populating DataRepeater control with multiple items based on some criteria. (24/7 player)

Why do you guys think? Is it safe to go with BackgroundWorker or is it better to look at the other Threading classes?

Upvotes: 2

Views: 434

Answers (2)

Tudor
Tudor

Reputation: 62439

Definitely use Tasks if .NET 4 is available. They have so many useful features:

  1. The ability to queue more work for the same Task when the current work has completed.
  2. Marshaling of exceptions to the calling thread.
  3. "Smart" scheduling.

and many more. Check this source for a good overview of what you can do.

Upvotes: 0

Haris Hasan
Haris Hasan

Reputation: 30097

Well if you are using .Net 4 or above I would recommend Task class rather than Background Worker

Task class is certainly improvement over BackgroundWorker. It has more flexibility. You can write more elegant code using Task than BackgroundWorker. For example you can avoid event handlers involved in BackgroundWorker by using concept of task continuation.

Upvotes: 1

Related Questions