Pages

Wednesday, October 30, 2013

Whats new in VS 2013 - Peek Definition

Along with some other awesome features of VS 2013. One of my favorites is peek definition.

This feature should have been a part of Visual Studio since day one, but since it was not there, no one really asked about it.

So here is how it really works.

In the previous versions of Visual Studio we had to use the "Go to Definition (F12)"  menu option on the right click menu or the context menu to view the code of some other function, but the problem with it was that the current view was updated and the developer had to track back to the previous location using 'CTRL' + '-' key or maybe closing the file in case the function was in another file

Now VS 2013 gives an option to peek into the definition of another function by opening another smaller window on top of the current code editor window to peek into the code.



Right Click Menu for Peek

Peek Window

Here, the developer can not only view the function but can also see other functions in the same code file by scrolling up and down in the same code file. A developer can also do all sorts of tasks that one can think of in a code editor window, because it is a fully functional code editor window itself.

The developer can get rid of that window by simply pressing the "escape" key.

Monday, October 28, 2013

What's new in Visual Studio 2013 - Hanselman Blog Post

I wanted to shed some light on this, but Mr. Scott Hanselman already did this and out of respect only I am going to share only the link of his blog where he has shared the videos of the new features of Visual Studio .Net 2013.

Here is a link to his blog, which shows top new features in Visual Studio 2013.

http://www.hanselman.com/blog/SCREENCASTSWhatsNewInVisualStudio2013LearnOverLunch.aspx

Enjoy the videos and enjoy the new features of Visual Studio .Net 2013

Friday, October 25, 2013

Converting Comma separated values to Temporary Table in T-SQL

Today, I want to share a technique that we have to use often in SQL while using with .Net. We have to pass a comma separated string into a Stored Procedure and use it as a table (somehow) to manipulate the results.

Since we had to pass the comma separated string to a stored procedure many times. We created a SQL Function for it and then we only had to call it.

Here is how the code for the T-SQL function looks like...

CREATE FUNCTION [dbo].[GetIDsTableFromIDsList]
(
      @IDsList VARCHAR(MAX)
)
RETURNS @IDsTable TABLE ( [ID] INT )
AS
    BEGIN
        DECLARE @ID VARCHAR(10)
        DECLARE @Pos 

        SET @IDsList = LTRIM(RTRIM(@IDsList)) + ','
        SET @Pos = CHARINDEX(',', @IDsList, 1)

        IF REPLACE(@IDsList, ',', '') <> ''
            BEGIN
                WHILE @Pos > 0
                    BEGIN
                        SET @ID = LTRIM(RTRIM(LEFT(@IDsList, @Pos - 1)))
                        IF @ID <> ''
                            BEGIN
                                INSERT  INTO @IDsTable
                                        ( [ID] )
                                VALUES  ( CAST(@ID AS INT) )
                            END
                        SET @IDsList = RIGHT(@IDsList, LEN(@IDsList) - @Pos)
                        SET @Pos = CHARINDEX(',', @IDsList, 1)
                    END
            END  
        RETURN

    END

This function receives a simple comma separated list of IDs and loops over the list and then after inserting all the values into a temporary table. It returns the temporary table

Wednesday, October 23, 2013

What's new in ASP.Net 4.5 - Garbage Collector

There are a few improvements shipped with .Net Framework 4.5, but the first one that I would share some details with, is Garbage Collection. If you would like to read the basics of the Garbage Collection read this

There are some performance improvements in the Garbage Collection process, which I would like to discuss here. GC is always a process which consumes both memory and the processor a lot and it has always been a problem area for websites running under .Net because the process for ASP.Net applications is continuously running and a lot of users are requesting the content and thus creating many objects on the fly and many of those objects are supposed to be destroyed by the GC too often. 

Whenever GC is trying to clean up the memory. It consumes a lot of resources and the GC thread suspends the main website threads and thus the other resources have to wait for the cleanup process to complete before serving further requests of the users.


GC Model in .Net 4.0

Previously (in .Net 4.0), if we could simulate the GC Thread along with ASP.Net website threads. The picture should be something like this...


GC Model in .Net 4.0

As you can see in the above figure that whenever the two processes of GC run (one for each logical processor). The other threads have to wait for the cleanup process to complete before carrying on with the tasks, so user feels the processes to be less responsive while the garbage collector is running.

GC Model in .Net 4.5

Now (in .Net 4.5), the GC Thread takes less time and consumes lesser time, so that other threads are not suspended for longer periods

GC Model in .Net 4.5


Microsoft introduced new features in server GC for .Net 4.5 and as you can see in this figure, the server GC has introduced a new thread for Garbage Collector which is running in the background and is collecting objects from Generation 2, so the main application threads do not suspend much, thus increasing overall application performance. 

Enable Server GC in Config

To enable server GC in your application, you only have to add this to your configuration file.

Enable GC in Config

  

For any queries, please comment below...

References: