Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
BRH 58
#ASP.NET 55
ASP.NET 50
#DOTNET 49
.NET 40
WCF 21
DOTNET 12
c# 8
windows azure 7
SILVERLIGHT 7

Archive · View All
April 2011 9
March 2011 9
February 2011 8
December 2010 7
November 2010 5
September 2010 5
August 2010 5
May 2011 4
October 2010 4
January 2011 2

Basic of C#: Call Stack, Call Site and Stack unwinding

Aug 16 2010 7:25AM by Dhananjay Kumar   

When we call a method in c# in a nested manner , there are three terms come into action. They are Call stack , Call Site and Stack unwinding This article is going to explain about that.

Objective

In this article, I will explain three basic terms of C#

  1. Call Stack
  2. Call Site
  3. Stack Unwinding

Let us say, you got the below code

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication7
{
    classProgram
    {
        staticvoid Main(string[] args)
        {
             Method1();   
             Console.Read();  
         }
        staticvoid Method1()
        {
            Method2();
            Console.WriteLine("Method1");
        }
        staticvoid Method2()
        {
            Method3();
            Console.WriteLine("Method2");
        }
        staticvoid Method3()
        {
            Method4();
            Console.WriteLine("Method3");
        }
        staticvoid Method4()
        {
            Method5();
            Console.WriteLine("Method4");
        }
        staticvoid Method5()
        {
            Console.WriteLine("Method5");
        }

    }
}

I have just created five dummy methods and calling them in nested manner. The methods, I have created are Method1 to Method5. If you run the above program , you will get output as below

Output

If you examine the output, Methods are being called in reverse order.

Program is putting the methods in stack as below,

Putting Methods in Stack

What is Call Stack?

Here, we are calling a method inside a method and so on and this is called CALL STACK.

Call Stack

Call Stack is the process of calling method inside a method.

Mathematically, we can say

Image

What is Stack Unwinding?

Once the method call is completed that method is removed from the stack and this process is known as Stack Unwinding.

Stack Unwinding

What is Call Site?

In above program, we are calling Method3 from Method2, so we can say Method2 is call site of Method3

Call Site

Tags: #DOTNET, DOTNET, #ASP.NET, ASP.NET, c#, BRH,


Dhananjay Kumar
49 · 4% · 1198
0
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]