- ~ Posted by Deepak Kamboj on September 14, 2011
- ~ Posted by Deepak Kamboj on July 11, 2011
During the past few years there was a requirement from various industries like manufacturing, utilities, oil & gas and financial services for incorporating “events” and “event streams” into the applications. The demand emerged for a technology to be created where we can looked upon these applications as “Complex Event Processing (CEP) Applications” or “Low Latency Monitoring Applications”. These applications were referred to by different names in different domains ranging from manufacturing, utilities, oil & gas, financial services and IT monitoring to web analytics. Still, all these applications shared some common characteristics – the need to process large volumes of data in the form of event streams with minimal latency. In some applications the emphasis was on the ability to process events with very rich payloads (complex events) and in others the emphasis was on the ability to compute with minimum latency over very large event rates. Microsoft released the Microsoft® StreamInsight as Microsoft’s new Complex Event Processing technology to help businesses derive better insights by correlating event streams from multiple sources with near-zero latency.
Microsoft StreamInsight™ is a powerful platform that you can use to develop and deploy complex event processing (CEP) applications. Its high-throughput stream processing architecture and the Microsoft .NET Framework-based development platform enable you to quickly implement robust and highly efficient event processing applications. Event stream sources typically include data from manufacturing applications, financial trading applications, Web analytics, and operational analytics. By using StreamInsight, you can develop CEP applications that derive immediate business value from this raw data by reducing the cost of extracting, analyzing, and correlating the data; and by allowing you to monitor, manage, and mine the data for conditions, opportunities, and defects almost instantly.
By using StreamInsight to develop CEP applications, you can achieve the following tactical and strategic goals for your business:
-
Monitor your data from multiple sources for meaningful patterns, trends, exceptions, and opportunities.
Analyze and correlate data incrementally while the data is in-flight -- that is, without first storing it--yielding very low latency. Aggregate seemingly unrelated events from multiple sources and perform highly complex analyses over time.
-
Manage your business by performing low-latency analytics on the events and triggering response actions that are defined on your business key performance indicators (KPIs).
Respond quickly to areas of opportunity or threat by incorporating your KPI definitions into the logic of the CEP application, thereby improving operational efficiency and your ability to respond quickly to business opportunities.
-
Mine events for new business KPIs.
-
Move toward a predictive business model by mining historical data to continuously refine and improve your KPI definitions.
Source: http://msdn.microsoft.com/en-us/library/ee362541.aspx
- ~ Posted by Deepak Kamboj on March 23, 2011
We have got an opportunity from Microsoft to meet industry top people and community members all over the India in this year 2011. Are you ready for the show? I do not want to give surprise now. It is Tech.Ed 2011.
You can join us the Tech.Ed 2011 event in Bangalore from 23-March-2011 to 25-March-2011 at LaLiT Ashok Hotel.
Below content is copied from http://www.microsoft.com/india/teched2011/default.aspx
The annual Microsoft Tech·Ed India 2011 is back. Join us for the largest technology event at Bangalore between March 23 - 25, 2011.
Microsoft Tech·Ed India 2011 is the premier technical education and networking event for tech professionals interested in learning, connecting and exploring a broad set of current and soon-to-be released Microsoft technologies, tools, platforms and services.
This 3-day event will focus on technical education, product evaluation and community. The event will include: Keynotes by Senior Microsoft Executives, Breakout Sessions, Hands-on-Labs, Instructor-led Labs, Product Team Tents, Free Microsoft Certification, Community Programs, Solution Expo, and many more social gatherings and opportunities for networking everywhere you look.
REGISTER NOW to attend the conference for hands-on learning, deep product exploration and opportunities to connect with industry and Microsoft experts one-to-one.
Please note: Tech·Ed India 2011 is a paid event
Register now, if you have not done yet.
Here are some of the sessions and technologies that you as a developer, architect or IT professional will get to be a part of:
Developers
• The Next Web using ASP.NET MVC & IIS
• The latest Visual Studio Tools
• Cloud services on Azure
Architects
• Niche topics under Web, Middleware, Data & Cloud
• Reducing project technical risk
• Patterns and Practices to shrink design & dev cycles
IT Professionals
• Denali release sneak peak
• Unified IT management from a single console
• Responding faster to front-line business needs
- ~ Posted by Deepak Kamboj on January 13, 2011

- ~ Posted by Deepak Kamboj on January 13, 2011
|  |
| |
Tera kaun vichara..ho Dulla Bhatti walla..ho Dulle ne ti viahiyi..ho Saer Shakar payi..ho Kudi de boje payee..ho Shallu kaun samete..ho Chacha galee dese..ho Chache choori kutee..ho Zamindaran lutee..ho Zamindara sidaye..ho Gin-gin pole layee..ho Ik pola reh gaya..ho Sipahi farh ke lei gaya..ho Aakho mundao taana.. Mukai da dana.. Aana lei ke jana... Wishing you lots of Happiness, Success, Love and Good health.. |
- Tags: lohri
- Categories: Personal
- ~ Posted by Deepak Kamboj on December 30, 2010

- ~ Posted by Deepak Kamboj on August 17, 2010
Today we will focus on the best practices for SQL Server Indexing. These practices are known to us and is a recap which will assure optimal performance through indexes.
1) Guidelines on indexing decisions
- Keep the columns in an index to a minimum as wide indexes take longer to scan.
- Ensure a clustered index on every table. The clustered index should be on an unique column and used most frequently for retrieving data
- The column of the clustered index should not be frequently updated as every time a clustered index is updated, SQL Server also maintains the non-clustered index along with the clustered index for the non-clustered index contains a pointer to the clustered-index.
- Eliminate duplicate indexes i.e., multiple indexes on the same set of columns. This adds to extra storage space and has a performance penalty on the INSERT, UPDATE and DELETE statements.
- Creation of indexes primarily depends on frequently executed queries and the queries most important to the users. Index tuning wizard and Database Engine Tuning Advisor are built-in tools for analysing and recommending indexes and analysing the performance of SQL Server instances but the recommendation are relevant for the workload supplied to the tool.
2) Determine the fragmentation state of indexes
Fragmentation happens due to inserts, updates and deletes. Get the list of all indexes on the database where fragmentation is 15% or greater and index page count is greater than 50. Work out plan to rebuild the heavily fragmented indexes and reorganize the lesser fragmented indexes.
3) Ensure the data type of surrogate primary keys is correct.
The best example here would be a transaction table which has a surrogate key of int data type. As the records cross the 2147483647 limit, the DBA would realize that the data type should not be an int. Ensure the database is scalable.
4) Understand the following myths are not true:
- Rebuilding the clustered index would rebuild all the associated non-clustered indexes. This is true only if the REBUILD WITH DROP EXISTING option is specified.
- Reorganizing a clustered index causes all non-clustered indexes to be reorganized.
- A fill factor of 0% is not the same as a fill factor of 100%.
- ~ Posted by Deepak Kamboj on August 15, 2010
Today is August 16 and I am very happy; it’s my Daughter’s Birthday, celebration time!!! She turns 4 today.
You are a special daughter
who means so much to me.
The day you were born,
there wasn't a lovelier sight to see.
I am glad God gave you to me.
Your love and devotion
has been my reason,
to get through many tough times,
and through many seasons.
As you have grown up,
your beauty shines through,
with a wonderful smile
that shows the real you.
You have a heart that is
made of gold
and I know it will stay that way,
as you grow old.
You make me proud
that you are who you are.
The bond that we have
will keep us close,
and no matter where you are,
you won't seem far.
The closeness we have
will never depart,
cause there is so much love
that connects you to my heart.
I am glad my daughter,
that you are mine,
because having you in my life
makes my sun shine.
Copyright by Judith Pleasant 2003
- ~ Posted by Deepak Kamboj on May 31, 2010
Ability to execute several tasks on different threads at the same time.Through Asynchronous call the main thread never blocked and another thread calls the method and gives the output to the main thread.
The problem with the ADO.Net 1.x is that one thread has to wait for the other thread to complete. So to overcome this problem Microsoft has introduced Asynchronous data access, through which one can execute multiple threads at a time.Asynchronous access to the results of multiple commands over the same Connection instance, plus the ability to open connections asynchronously. A database operation is normally a synchronous operation, meaning that the caller regains the control of the application only when the interaction with the database has completed.This way of working may pose performance and scalability issues incases of lengthy operations. ADO.NET 2.0 provides true asynchronous support for two specific scenarios: opening connections and executing commands. Leveraging these features, you can open a connection and populate the command object while the connection is physically established. This is a clear performance advantage, because it really gives you a bit of parallelism if SQL Server lives on a remote machine.
Although asynchronous execution can be a nice feature, it should not be used gratuitously; only use it if you know the command can run for a long time and also that you have something useful to do at the same time. The Windows thread scheduler in the Windows NT family of operating systems (the feature is not available on Windows 9x and ME clients) takes overhead of its own to switch between threads. Also bear in mind that some .NET libraries are thread-sensitive; using asynchrony, the thread that you use to start the operation won't necessarily be the same thread it finishes on. Not only can asynchronous operation be effective for multiple action statements and stored procedure execution, when used with the Multiple Active Result Sets (MARS) feature in SQL Server 2005, you can multiplex asynchronous SELECT statements using a single database connection.
Asynchronous code is difficult to write and debug, more advanced coding skills are required.
Executing Multiple Commands Sequentially An alternative situation is when you use several object instances to access data (here multiple DataReader instances, but it could be a mix of DataReader and DataSet instances) over the same connection. Again,only one of these can be executing a query over the single connection at a time. But because the ADO.NET code you write will usually call methods on the DataReader or other objects sequentially and will block on each method call until it is complete, there is no problem with using the same connection. Figure below shows this scenario.

this case, however, there are two areas where performance and usability issues can arise:
1. If you open a rowset with a DataReader over the connection, you must close it before you attempt to open another DataReader or execute another command�if not, you�ll get a �Connection is busy . . .� error.To be able to open more than one rowset concurrently in ADO.NET version1.x requires that each command have its own separate connection to the database. Because the number of database connections available islimited and they are expensive in terms of resource usage, this often is not a feasible approach.
2. If one of the commands you�re executing takes a long time to return results, the code in the application will block and wait until the query process is complete before it can execute the next command.
So your code may be standing idle when it could be doing something else in the meantime.
New API Elements
We modeled the new ADO.NET asynchronous API after the existing APIs in the .NET Framework, with similar functionality. Consistency is an important thing in large frameworks
Asynchronous Methods
All command execution APIs are in the Command object in ADO.NET,including ExecuteReader, ExecuteNonQuery, ExecuteXmlReader andExecuteScalar. We decided to minimize the API surface that we added forthis feature, so we added asynchronous versions only for the methodsthat couldn't be adapted from other methods: ExecuteReader,ExecuteNonQuery and ExecuteXmlReader. ExecuteScalar is simply a short form of ExecuteReader + fetch first row/first column + close the reader, so we didn't include an asynchronous version of it.
Following the asynchronous API pattern already in use in the .NET Framework, each existing synchronous method has now an asynchronous counterpart that's split into two methods; a begin part that starts the work, and an end part that completes it. The table below summarizes the new methods in the command object:
Table 1. New asynchronous methods available in ADO.NET 2.0

The asynchronous pattern models methods, so the begin method takes all the input parameters, and the end method provides all the output parameters, as well as the return value. For example, here is what an asynchronous invocation of ExecuteReader lookslike.
The "async" Connection String Keyword
In order to use asynchronous commands, the connections on which the commands will be executed must be initialized with async=true in the connection string. An exception will be thrown if any of the asynchronous methods are called on a command with a connection that doesn't have async=true in its connection string.
BeginExecuteReader
Starts an asynchronous query to the data source that is expected to return some rows. The return value is a reference to an object that implements the IAsyncResult interface, in this case an instance of the SqlAsyncResult class, which is used to monitor and access the process as it runs and when it is complete.
Ex : async-result = command.BeginExecuteReader(callback, state)
It takes an AsyncCallback instance that specifies the callback routine to be executed when the process is complete, plus an Object that defines state information for the process.
EndExecuteReader
Once the command execution started by a BeginExecute Reader call hascompleted, this method is called to access the results. The single parameter is a reference to the SqlAsyncResult for the command, and themethod returns a DataReader that references the rowset(s) returned by the query (in the same way the ExecuteReader method does for synchronous processes).
Ex: data-reader = command.EndExecuteReader(async-result).
Models in Asynchronous
1. The Asynchronous Polling Model
The simplest approach to handling asynchronous execution of one or more commands is through the polling model. It simply involves starting off the and then repeatedly checking the IsCompleted property of the SqlAsyncResult instance until it returns True.Of course, the code can go off and do other things between checking to see whether the process is complete. However, this approach is notrecommended unless it is a simple and "tight" loop that handles aspecific required task and uses only minimal processing time. If there are large or unrelated tasks to accomplish, you should consider using the callback or wait models instead.
2. The Asynchronous Callback Model
Thesecond approach to asynchronous execution involves providing a routine in the code that will act as a callback. It will be executed when the action you specify occurs, rather like the way that an event handler is called to handle a user�s
interaction with an application.To specify the callback routine you create a new instance of the AsyncCallback class, providing the name of that routine as the parameter,and pass this AsyncCallback instance into the method you use to start execution of the command. Asynchronous technique employs the familiar asynchronous programming model using the AsyncCallback delegate in.NET, and so includes the SqlAsyncResult class to implement the IAsyncResult interface. While this feature works only for SqlClient at the moment.IAsyncResult Interface : Represents the status of an asynchronousoperation.The IAsyncResult interface is implemented by classes containing methods that can operate asynchronously. An object that supports the IAsyncResult interface stores state information for an asynchronous operation, and provides a synchronization object to allow threads to besignaled when the operation completes.
3. The Asynchronous Wait Model
The mostcomplex of the asynchronous methods is also the most efficient if all you want to do is start some commands running against one or more datasources (they can all use separate connections and therefore different databases if required) and not execute other code in the meantime. You simply want to wait until one, more, or all of the commands have completed and then perhaps display some results. In this case, you start each process in the same way as the previous examples but then use the AsyncResult to create a WaitHandle that you use to monitor each process.
The following code explains the usage of techniques of asynchronous programming and multithreading.
Asynchronous Callback Model Example:
1: using System;
2: using System.Data;
3: using System.Data.SqlClient;
4:
5: // You'll need this delegate in order to fill the grid from a thread other than the form's thread. See the Callback1
6: //procedure for more information.
7: private delegate void DelFillGrid(SqlDataReader reader);
8:
9: // You'll need this delegate to update the status bar.
10: private delegate void DisplayStatusDelegate(string Text);
11:
12: // It indicates whether asynchronous command is active or closed.
13: private bool isExecuting = false;
14:
15: private SqlConnection conn = null;
16:
17: private void DisplayStatus(string Text)
18: {
19: this.label1.Text = Text;
20: }
21:
22: private void FillGrid(SqlDataReader dr)
23: {
24: try
25: {
26: DataTable dt = new DataTable();
27: dt.Load(dr);
28: this.dataGridView1.DataSource = dt;
29: DisplayStatus("Ready");
30: }
31: catch (Exception ex)
32: {
33: // Because you're guaranteed this procedure
34: // is running from within the form's thread,
35: // it can directly interact with members of the form.
36: DisplayStatus(string.Format("Ready (last attempt failed: {0})", ex.Message));
37: }
38: finally
39: {
40: // Don't forget to close the connection, as well.
41: if (dr != null)
42: {
43: dr.Close();
44: }
45: if (conn!= null)
46: {
47: conn.Close();
48: }
49: }
50: }
51:
52: private void btnAsync_Click(object sender, System.EventArgs e)
53: {
54: if (isExecuting)
55: {
56: MessageBox.Show(this, "Already executing. Please wait until the current query " + "has completed.");
57: }
58: else
59: {
60: SqlCommand command = null;
61: try
62: {
63: DisplayStatus("Connecting…");
64: //To Execute the command asynchronously we need to make Asynchronous Processing=true
65: conn= new SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind; );
66: Asynchronous Processing=true"
67: // To emulate a long-running query, wait for a few seconds before retrieving the real data.
68: command = new SqlCommand();
69: command.CommandText = "WAITFOR DELAY '00:00:05' : SELECT * FROM Customers" ;
70: command.Connection = conn;
71: conn.Open();
72:
73: DisplayStatus("Executing…");
74: isExecuting = true;
75:
76: //Passing the SQLCommand as a parameter makes easier to call EndExecuteReader();
77: AsyncCallback callback = new AsyncCallback(Callback1);
78: command.BeginExecuteReader(callback, command);
79: }
80: catch (Exception ex)
81: {
82: DisplayStatus("Error: " + ex.Message);
83: if (conn!= null)
84: {
85: conn.Close();
86: }
87: }
88: }
89: }
90:
91: private void Callback1(IAsyncResult result)
92: {
93: try
94: {
95: // To retrieve the original command object.
96: SqlCommand command = (SqlCommand)result.AsyncState;
97: SqlDataReader dr = command.EndExecuteReader(result);
98: // To execute the code from a different thread instead of main thread.
99: DelFillGrid del = new DelFillGrid(FillGrid);
100: // To call the form's delegate.
101: this.Invoke(del, dr);
102: // Reader is to be closed at the end, as some thread may be using it. Use seperate procedure to close it
103: }
104: catch (Exception ex)
105: {
106: // We are running the code in a seperate thread so we need to catch the exception.
107: // Else we are unable to catch the exception anywhere.
108: this.Invoke(new DisplayStatusDelegate(DisplayStatus), "Error: " + ex.Message);
109: }
110: finally
111: {
112: isExecuting = false;
113: }
114: }
115:
116: private void Form1_Load(object sender, System.EventArgs e)
117: {
118: this.btnAsync.Click += new System.EventHandler(this.btnAsync_Click);
119: this.FormClosing += new FormClosingEventHandler(Form1_FormClosing);
120: }
121:
122: void Form1_FormClosing(object sender, FormClosingEventArgs e)
123: {
124: if (isExecuting)
125: {
126: MessageBox.Show(this, "Can't close the form until " +
127: "the pending asynchronous command has completed. ");
128: e.Cancel = true;
129: }
130:
131:
Summary
Asynchronous access to the results of multiple commands over the same Connection instance, plus the ability to open connections asynchronously
Main Features
- Ability to switch execution to another thread
- Ability to make calls to network resources in a way that does not block any threads
- Important for high-end 3-tier server applications
Original Source: http://www.csharphelp.com/2007/07/asynchronous-data-access-using-callback-model/
- ~ Posted by Deepak Kamboj on May 31, 2010
IIS combined with ASP.NET provides many technologies to improve performance and scalability. IIS provides a pool of threads so that it can server many requests simultaneously. The pool has a limited number of threads in it, and once they are used up additional requests can start to pile up. Keeping the total number of active threads down is an attempt to prevent too many active threads from consuming all of the available CPU time. However, with today's data intensive websites, much of the time threads are tied up waiting for an external resource such as a request from a web service or from a database. Asynchronous pages in ASP.NET can boost performance in these situations by enabling threads in the pool to be used to serve additional requests while an operation is waiting for an external resource request to complete.
Suppose you have a website with two web pages. One is your home page which display's a greeting, and the second page displays a large dataset from a database. You have 25 threads in your thread pool. 25 people simultaneously are accessing the database query page, and one additional person comes onto the site to see the home page which has static content on it.
Compare these two scenarios:
Synchronous database driven page: While everyone is waiting for the dataset to load, all available threads are in use so the 26th request for the home page becomes blocked.
Asynchronous database driven page: While 25 requests are waiting for data from the database, those threads are returned to the pool for work. When the 26th request comes in for the home page, that page is returned immediately. As the datasets are returned the threads are drawn out of the thread pool to finish serving the pages. The result is that the threads spend much more time available to serve requests.
Here are two good pages for getting started with asynchronous ASP.NET pages:
Asynchronous ASP.NET Page Processing by Peter Bromberg
http://www.eggheadcafe.com/articles/20060918.asp
Use Threads and Build Asynchronous Handlers in Your Server-Side Web Code by Fritz Onion
http://msdn.microsoft.com/msdnmag/issues/03/06/threading/default.aspx
After reading these and some other articles, here is a piece of code to get you started. I put this together to process a job in the background as a generic pattern. I wrap my big job in a delegate so that I can get an IAsyncResult object back. This simplifies things, because in most examples I read you get this by calling a web service asynchronously but this isn't always what you want done.
Step 1: Make an empty asp.net page. Add async="true" to the @Page tag in the .aspx file.
Step 2: In the class code, declare a delegate
public delegate void AsyncTaskDelegate();
Step 3: Declare a member variable in the class to prevent the delegate from going out of scope
AsyncTaskDelegate _runnerDelegate = null;
Step 4: Create a method that will be run asynchronously:
public void DoJob()
{
this.GridView1.DataSource = GetDatasetFromDatabase(); this.GridView1.DataBind();
}
Step 5: Tell the framework you want your job run. You can put this in Page_Load or in a response to a button click / postback:
// Register async methods
AddOnPreRenderCompleteAsync(
new BeginEventHandler(OnBegin),
new EndEventHandler(OnEnd)
);
Step 6: Add the event to kick off the delegate and run the job asynchronously.
IAsyncResult OnBegin(object sender, EventArgs e, AsyncCallback cb, object state)
{
_runnerDelegate = new AsyncTaskDelegate(this.DoJob);
IAsyncResult result = _runnerDelegate.BeginInvoke(cb, state);
return result;
}
Step 7: Add an event handler for after the request finishes
void OnEnd(IAsyncResult ar)
{
_runnerDelegate.EndInvoke(ar);
}
All together, it looks like this:
1: public partial class Async : System.Web.UI.Page
2: {
3: public delegate void AsyncTaskDelegate();
4:
5: AsyncTaskDelegate _runnerDelegate = null;
6:
7: IAsyncResult OnBegin(object sender, EventArgs e, AsyncCallback cb, object state)
8: {
9: _runnerDelegate = new AsyncTaskDelegate(this.DoJob);
10: IAsyncResult result = _runnerDelegate.BeginInvoke(cb, state);
11: return result;
12: }
13:
14: public void DoJob()
15: {
16: this.GridView1.DataSource = new AsyncTaskDelegate(this.DoJob);
17: this.GridView1.DataBind();
18: }
19:
20: void OnEnd(IAsyncResult ar)
21: {
22: _runnerDelegate.EndInvoke(ar);
23: }
24:
25: protected void Button1_Click(object sender, EventArgs e)
26: {
27: // Register async methods
28: AddOnPreRenderCompleteAsync(
29: new BeginEventHandler(OnBegin),
30: new EndEventHandler(OnEnd)
31: );
32: }
33:
34: }
Original Source: http://davidjberman.com/blogs/csharp/archive/2007/08/13/how-to-create-asynchronous-asp-net-pages-using-c.aspx
- Tags: c#
- Categories: C# | ASP.NET | .NET Framework