This .Net class library is designed to integrate into enterprise applications to help support their high performance and reliability requirements. The focus of the Enterprise Library is to provide simple and robust mechanisms that take full advantage of the amazing capabilities already in the .Net Framework and extend those capabilities to support the needs of enterprise applications. The first major component of the library is the Operations Framework. The Operations Framework provides flexible and efficient support for asynchronous operations that can fully utilize the power of computers with multiple processors and make I/O operations much faster.

Operations Framework

The library contains the Operations Framework, which is designed to make working with asynchronous tasks simple, robust, and performant. The operation classes are easy to integrate into your code. They help you avoid common mistakes in your code by releasing resources automatically at the right times (including closing database connections), synchronizing work done on multiple threads efficiently, taking advantage of I/O completion ports, and handling critical exceptions correctly (including OutOfMemory, StackOverflow, and ThreadAbort). They make the most of the .Net Framework by leveraging the power of the thread pool, ADO.Net connection pool, and timers. They help you solve common problems by including support for customizable automatic retries, accurate timeouts, efficient parallel execution, and flexible transactions. As demonstrated in the following examples, these capabilities are highly useful when communicating with a database such as SQL Server.

Code Example

These examples show how easy it is to create highly efficient and reliable code to execute several database commands.
using FishDawg.EnterpriseLibrary.Operations;

// Create 3 SQL commands.
const string connectionString = "Server=.....;Database=.....;MultipleActiveResultSets=True;Asynchronous Processing=True";
const string commandText1 = "INSERT LogEntry (Code, Message) VALUES (111, N'AAA');";
SqlCommand command1 = new SqlCommand(commandText1, new SqlConnection(connectionString));
const string commandText2 = "INSERT LogEntry (Code, Message) VALUES (222, N'BBB');";
SqlCommand command2 = new SqlCommand(commandText2, new SqlConnection(connectionString));
const string commandText3 = "INSERT LogEntry (Code, Message) VALUES (333, N'CCC');";
SqlCommand command3 = new SqlCommand(commandText3, new SqlConnection(connectionString));
private static void Example1()
{
  // Compose together several operation objects to execute the 3 SQL commands with a timeout in parallel, each in a local transaction 
  // with automatic retries (of up to a maximum of 3 tries by default) when a database or transaction exception gets thrown.
  RetryPolicy retryPolicy = new ExceptionTypeRetryPolicy(typeof(SqlException), typeof(TransactionException));
  using (Operation operation = new TimeoutOperation(new ParallelOperation(
      new RetryOperation(new TransactionOperation(new NonQuerySqlOperation(command1), TransactionOption.CreateNew), retryPolicy),
      new RetryOperation(new TransactionOperation(new NonQuerySqlOperation(command2), TransactionOption.CreateNew), retryPolicy),
      new RetryOperation(new TransactionOperation(new NonQuerySqlOperation(command3), TransactionOption.CreateNew), retryPolicy)
    ), TimeSpan.FromSeconds(30.0)))
  {
    // Execute the operation asynchronously (omitting the callback delegate for demonstration purposes only)
    IAsyncResult asyncResult = operation.BeginExecute(null, null);
    operation.EndExecute(asyncResult);
  }
}
private static void Example2()
{
  // Compose together several operation objects to execute the 3 SQL commands with a timeout in parallel, in a distributed transaction 
  // (which participates in the ambient transaction if one exists) with a timeout of 20 seconds and the read committed isolation level.
  using (Operation operation = new TimeoutOperation(new TransactionOperation(new ParallelOperation(
      new NonQuerySqlOperation(command1),
      new NonQuerySqlOperation(command2),
      new NonQuerySqlOperation(command3)
    ), TransactionOption.Create, TimeSpan.FromSeconds(20.0), IsolationLevel.ReadCommitted), TimeSpan.FromSeconds(30.0)))
  {
    // Execute the operation synchronously.
    operation.Execute();
  }
}

Releases

Version 2.0 of the framework is now available. It has been thoroughly tested with unit tests and in a large-scale real-world application. See the Releases page to download the binaries, source code, documentation, and sample web application.

Library Usage

The project's default license is a modified form the BSD permissive free software license. For non-commercial, internal business, evaluation, academic, and research purposes, you may freely use the library, its source code, and its documentation in your project. For other purposes, such as commercial applications used directly by your customers, you can obtain a commercial license by contacting the project coordinator. We encourage everyone to contribute to the project by requesting features, reporting bugs, and writing code.
Last edited Oct 23 at 7:07 AM by FishDawg, version 24

 

Want to leave feedback?
Please use Discussions or Reviews instead.

Updating...
© 2006-2009 Microsoft | About CodePlex | Privacy Statement | Terms of Use | Code of Conduct | Advertise With Us | Version 2009.10.27.15987