Search Wiki:
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, 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=...;Integrated Security=True;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 in parallel, each in a local transaction with automatic 
  // retries (of up to a maximum of 3 tries by default) when a SqlException gets thrown.
  using (Operation operation = new ParallelOperation(
      new RetryOperation(new TransactionOperation(new SqlNonQueryOperation(command1), TransactionOption.CreateNew), typeof(SqlException)),
      new RetryOperation(new TransactionOperation(new SqlNonQueryOperation(command2), TransactionOption.CreateNew), typeof(SqlException)),
      new RetryOperation(new TransactionOperation(new SqlNonQueryOperation(command3), TransactionOption.CreateNew), typeof(SqlException))
    ))
  {
    // 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 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 TransactionOperation(new ParallelOperation(
      new SqlNonQueryOperation(command1),
      new SqlNonQueryOperation(command2),
      new SqlNonQueryOperation(command3)
    ), TransactionOption.Create, TimeSpan.FromSeconds(20.0), IsolationLevel.ReadCommitted))
  {
    // Execute the operation synchronously.
    operation.Execute();
  }
}


Releases

Please note that the first version of the framework is under active development at this time. No download is available yet.

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 posting lots of feature requests, bug reports, and code enhancements.
Last edited Jun 26 at 5:16 AM  by FishDawg, version 20
Comments
No comments yet.

Updating...