Sunday, November 25, 2007

Enable Tracing


Requestlimit = 50 that is it will stop tracing if 50 is over.
The default request limit is 10

Sort a List of Generics using anonymous method

I bumped across a code in my project where they use anonymous method to do sorting which was pretty difficult to understand. So I decided to write my own piece of code to understand how this stuff works:
******************************************************************************
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
List dinosaurs = new List();

Console.WriteLine("\nCapacity: {0}", dinosaurs.Capacity);

dinosaurs.Add("Tyrannosaurus");
dinosaurs.Add("aAmargasaurus");
dinosaurs.Add("Mamenchisaurs");
dinosaurs.Add("Deinonychus");
dinosaurs.Add("Compsognathus");

Console.WriteLine("\nCapacity: {0}", dinosaurs.Capacity);
Console.WriteLine("Count: {0}", dinosaurs.Count);
foreach(string dinosaur in dinosaurs)
{
Console.WriteLine("dinosaur before Sort"+dinosaur);
}

dinosaurs.Sort(delegate(string r1, string r2)
{
if(r1.Length == r2.Length)
{
return r1.CompareTo(r2);
}
else{
return r1.Length.CompareTo(r2.Length);
}
});

foreach(string dinosaur in dinosaurs)
{
Console.WriteLine("dinosaur after Sort"+dinosaur);
}


}
}
}
******************************************************************************The most difficult portion to understand was
dinosaurs.Sort(delegate(string r1, string r2)
I really dint understand how r1 and r2 picks up the correct values. The issue is its so randomly picks up values and sometimes r1 == r2

Visual Studio Website and Ajax

WebSite also has Ajax Tool Kit and Extension Toolbox but it will not work. Ajax works only in Ajax Enabled website but what is frustrating is there are no warning signals in ordinary web-site. In Website project we are able to drag the Ajax control, code it and also execute. When we execute we are asking for a partial render but is not happening and we’ve to later find out that we’ve to use the Ajax Enabled one.

Should ASP.NET use Parallel Class?

Scott Hanselman: Cool. Cool. My second question was if I'm imagining kind of a typical web application scenario where one client hits a website and when in the past that single thread would then go to an ASP.NET server, which would then call to a database, maybe I started doing parallelism and then one person hitting my web server now ends up being four connections to my database and that becomes a standard thing because I started being very familiar with these technologies, it seems to be like that would dramatically change the scale signature of the entire application and would potentially get me then diskbound quicker. If I'm ultimately not going to become CPU-bound as much, I'm going to become diskbound, but people are saying already that machines are fast and then CPUs are barely working and then ultimately we are IO-bound. So, what does this kind of parallelism mean when it comes to IO-intensive operations?
Stephen Toub: That's sort of two different questions and I'd like to address the first one, which is basically, what does this parallelism stuff have to do with the server? In general, server apps today like ASP.NET, they already have enough parallelism to satisfy the CPUs. So, you take a typical ASP.NET application, it's getting thousands of requests per second, if each of those requests can be isolated, if it's n ot accessing shared state or anything like that, you're already introducing a thousand different asynchronous pieces of work. So, unless you're expecting very few requests into your web server and unless each of those very few requests is doing a ton of computation w o r k , using parallel class, for example, in your server application might not buy you all that much, which ties into your second question. Because, like you say, a lot of stuff is IO-bound in server world and so you take something like asynchronous pages in ASP.NET, it's basically meant to limit the number of thread pool resources you're consuming and maximize your throughput while at the same time basically making sure that you're not blocking other people from requesting your server resources just because you're waiting for the database to come back or you're waiting for a web service call to return or something like that. So, a lot of the technologies that we're working on right now, we're focusing largely at desktop or at backend data processing, not so much at the web server world because for the most part your frontend web applications have enough concurrency to go around.
Taken from Parallel Programming with .net Hanselminutes

Amdah's Law

Amdahl's Law that talks about the relative speedups you can expect in your application based on how much the application is serial and how much of it is parallel. So, if a very small portion of your application is parallel, even if we were to increase by 100X, the speed at which that parallel section runs, if it's still dominated by the serial portion, you're not going to overall see monstrous speedups. However, if that small portion of your application is working on data and over time you expect the amount of data your application is processing to grow exponentially, well, then the benefits of parallelizing that small portion is going to make a significant impact or theoretically could.
Taken from Parallel Programming with .net Hanselminutes

Optimal Threads in one Processor is one assuming that its is a CPU operation
Taken from Parallel Programming with .net Hanselminutes

Process and Processor

Scott Hanselman: Help me understand when we say multi-core machines, if I have a single process that's running on a machine with four processors, is there agility? If I have multiple threads, are those threads jumping between? I don't quite understand how the hardware works. I always used to think it was one process gets pinned to a processor.
Stephen Toub: Only if you want it to. You'd actually have to express that either as the user in, for example, Task Manager or as a developing setting thread affinity and process affinity for particular processors, but by default, no. There is no affinity. If you have a process that uses only one thread, by default, that process will ever only be running on one processor at a time, but it can certainly move around from processor to processor. Ideally, it won't for a lot
of subtle reasons like making sure that caches aren't invalidated and the memory that the -- well, that
caches aren't invalidated is good enough, but if the process has in it multiple threads and let's say in your case it has four threads, each of those four threads can be running one on each processor at the same time.
Scott Hanselman: Who decides that?
Stephen Toub: For the most part, it's t h e operating system unless as a developer you go ahead and say, "This thread here, I really want to tie to processor 3," in which case you can set an affinity mask that says, "Never let the operating system only allow this thread to run on processor 3 and if processor 4 is available and there's absolutely nothing happening on it, sorry, you can't run this thread until processor 3 is available."
Taken from Parallel Programming with .net Hanselminutes

Control State in GridView

Here's the list of properties that are saved into control state in GridView:
edit index, page index, selected index, sort expression, sort direction and data key names and values. So here even if you clear the ViewState these states still persist

Serializable is non-inherited

Even if a class inherits from a Serializable class is still not serializable. We need to explicitly specify [Serializable] for this class also. In other words Serializable is not inherited or can I say attributes are not inherited.

Issue with inline sql

Everybody knows that there is a performance overhead with in line sql statements.
There is yet another issue which is maintainability a DB guy changes some schema and he usually looks into all the DB Objects like SPs and functions but will never look into the .NET code. Everybody will come to know abut the issue only when the code breaks.

adv of Clone in .net

When u copy an object it actually copies the reference.
So if Obj A is copied by Obj B and say after sometime some values in Obj A changes then Obj B also changes.
If we clone its called “shallow copying” and the above issue will not occur.

Back Button and SessionSate

Usage of Go.History(-1) so when u click back button kills the session state of the page.
So it’s always worthwhile to load the page again using some means (like have a session state from the current page to the prev page and then loading the prev page afresh)

Tuesday, November 6, 2007

Cannot use SQLServer Destination when the SQLServer is not Local

Cannot use SQL Server as destination when the System does not have the DB Server locally.
In other words if we are trying to run SSIS remotely then use OLE DB as destination even if
The destination is SQL Server.