First step to create a video sharing library we need to have
all videos in a FLV flash format in order to play them on webpage,
Sounds familiar, yeah the famous youtube.com does that, how exactly we can do something similar to youtube?
How to convert files uploaded by
people in FLV format?
There are different open source tools available for
converting different formats of videos to other formats, unfortunately there
are issues and bugs in these tools, and less support, we can not use one tool for convert videos in FLV format, we have to mix two different tools for this purpose, below are the steps how can
we achieve that using FFMPEG and FLVTOOL.
Step # 1:
Download FFMPEG (search it on Google, download it build it)
Download FLVTOOL (search it on Google, download it build it)
Transactional isolation is usually implemented by locking
whatever is accessed in a transaction. There are two different approaches to
transactional locking: Pessimistic locking and optimistic locking.
The disadvantage of pessimistic locking is that a resource
is locked from the time it is first accessed in a transaction until the
transaction is finished, making it inaccessible to other transactions during
that time. If most transactions simply look at the resource and never change
it, an exclusive lock may be overkill as it may cause lock contention, and
optimistic locking may be a better approach. With pessimistic locking, locks
are applied in a fail-safe way. In the banking application example, an account
is locked as soon as it is accessed in a transaction. Attempts to use the
account in other transactions while it is locked will either result in the
other process being delayed until the account lock is released, or that the
process transaction will be rolled back. The lock exists until the transaction
has either been committed or rolled back.
Pessimistic locking
in ADO.NET
One way to deal with optimistic concurrency issues in
ADO.NET is to lock records as they are retrieved from the data source. It
doesn't take much code, but it does involve some risks. Find out when you
should use this procedure and how it works.
Six steps to implement Pessimistic Locking in ADO.NET
Create a transaction by using IsolationLevel of RepeatableRead.
Set the DataAdapter’s SelectCommand property to use the
transaction we have created in step #1.
Make the changes to the data.
Set DataAdapter’s Insert, Update, and Delete command
properties to use the transaction created in step #1.
Call the DataAdapter’s Update method.
Commit the transaction.
Below is an example using pessimistic locking by using
ADO.NET, developer just need to create object of the class mentioned below, select
data in DataSet, update it with required changes, then call submitChanges
method to save it into database, by using pessimistic locking procedure.
Pessimistic locking is pre-implemented in LINQ to SQL,
however we need to user TransactionScope class
in order to use pessimistic locking.
If two different instances of same program trying to update
a data rows set (collection of LINQ
objects) or even different programs, first program who ever update the
selected data will be saved in database, reset of others will get following
exception :
Unhandled Exception: System.Data.Linq.ChangeConflictException: Row
not found or changed.
Because of the fact that before updating LINQ to SQL first
tried to select the same row using a where clause with all old values.
Below is an example of using pessimistic locking using LINQ
to SQL and TransactionScope
using (TransactionScope ts = newTransactionScope())
Incase of voilation of pessimistic locking user
may encounter follwing exception:
Unhandled Exception: System.Data.SqlClient.SqlException: Transaction
(Process ID 52) was deadlocked on lock resources with another process and has been chosen as the deadlock victim.
Rerun the transaction.