Monday, 22 December 2014

Multi-threading in C#,Multithreaded Programming Using C#


Hai friend today I am going to say about Multithreaded Programming Using C#
In .net Multithreaded stands for executing the code parallel when we take two methods  and execute the code is executed sequential manner the code first method and then come to second method .if u want to code execute parallely we go for Multithreaded concept 

Program:

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Thread obj1 = new Thread(data1);
            Thread obj2 = new Thread(data2);
            obj1.Start();
            obj2.Start();
           
        }

        public static void data1()
        {
            for (int i = 0; i <= 10; i++)
            {
                Console.WriteLine("this is my data" + i.ToString());
            }
        }

        public static void data2()
        {
            for (int i = 0; i <= 10; i++)
            {
                Console.WriteLine("this is my newdata" + i.ToString());
            }
            Console.ReadLine();
        }
    }
}

  Output:



  




Threads are of two type Fore Ground thread and background thread
When coming to Fore Ground thread even your main application quit then also they will thread complete their task
When come to back ground threads which will quit whenever main application quit

Wednesday, 3 December 2014

Data Table manipulation techniques 1

Data Table manipulation techniques :

Hai friend today I am going to explain about Data Table manipulation techniques in asp.net ..it is one of the techinques used to take the query from the dataset..
For example if u have reterive data from table using dataset then use data in front end don’t go for other sql query for database

        
  protected void Page_Load(object sender, EventArgs e)
        {
            grddata.DataSource = registertable();
            grddata.DataBind();
          
        }

        public DataTable registertable()
        {
            dt = new DataTable();
            dt.Columns.Add("sno");
            dt.Columns.Add("name");
            dt.Columns.Add("salary");
            dt.Columns.Add("designation");
            dt.Rows.Add("1001", "sharth", "100000", "dotnet");
            dt.Rows.Add("1002", "ramesh", "40000", "java");
            dt.Rows.Add("1003", "rakesh", "100000", "testing");
            dt.Rows.Add("1004", "shiva", "100000", "java");

          
                DataTable dt2 = new DataTable();

                   dt2 = dt.Select("salary=100000").CopyToDataTable();

                   ViewState["datanew"] = dt2;
                   grddata2.DataSource = dt;
                   grddata2.DataBind();
                

                   return dt2;
          

           



              

        }

Tuesday, 2 December 2014