Friday, 14 March 2014

Simple Tick Tock Program in C#.net , Displaying Thread Synchronization

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace thread
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        object objlock = new object();

        public void tick()
        {
           
            for (int i = 0; i < 10; i++)
            {
                lock (objlock)
                {
                    textBox1.Text += "Tick"+Environment.NewLine;

                    Monitor.Pulse(objlock);
                    Monitor.Wait(objlock);
                }
            }
        }
        public void tock()
        {
           
            for (int i = 0; i < 10; i++)
            {
                lock (objlock)
                {
                    textBox1.Text += "Tock";

                    Monitor.Pulse(objlock);
                    Monitor.Wait(objlock);
                }
            }
        }
       // public void toe()
       // {
//
        //    for (int i = 0; i < 10; i++)
         //   {
          //      lock (objlock)
           //     {
            //        textBox1.Text += "Toe";
//
              //      Monitor.Pulse(objlock);
               //     Monitor.Wait(objlock);
               // }
           // }
     //   }

        private void Form2_Load(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Thread th = new Thread(tick);
            Thread th1 = new Thread(tock);
            //Thread th2 = new Thread(toe);

            th.Start();
            th1.Start();
           // th2.Start();

        }

    }
}

Saturday, 8 March 2014

Progress Bar Race Using Thread C#.NET

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace thread
{
    public partial class Form1 : Form
    {
     
        public Form1()
        {
            InitializeComponent();
        }
       

        bool flag=true;
       
        public void prog1()
        {
            //Change Property of progress bar
            //min=1
            //max=50000
            //size=127, 23

            for (int i = 1; i <= 50000; i++)
            {
                if (flag)
                {
                    progressBar1.Value = i;
                    textBox1.Text = i.ToString();
                    //Uncomment below code for simple progress bar

                    //if (progressBar1.Value == 100)
                    //{
                    //  MessageBox.Show("Progress Bar1 done");
                    //break;

                    //Uncomment above code for simple progress bar
                }
                else
                {
                 
                    break;
                }
            }
            flag=false;
         
        }
        public void prog2()
        {
            //Change Property of progress bar
            //min=1
            //max=50000
            //size=127, 23

            for (int i = 1; i <= 50000; i++)
            {
                if (flag)
                {
                    progressBar2.Value = i;
                    textBox2.Text = i.ToString();
                    //Uncomment below code for simple progress bar

                    //if (progressBar2.Value == 100)
                    //{
                    //    MessageBox.Show("Progress Bar2 done");
                    //    break;

                    //Uncomment above code for simple progress bar
                }
                else
                {
                   
                    break;
                }
               
            }
            flag=false;
        }
           

        private void Form1_Load(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Thread th1 = new Thread(prog1);
            Thread th2 = new Thread(prog2);

         
            th1.Start();
            th2.Start();
           
        }
    }
}

Wednesday, 5 March 2014

Horizontal Menus With Vertical SubMenus Using Css : Very Basic

<html>
<head>
<style>

body ul ul
{
display:none;
text-shadow:10px 5px 5px red;


}

body ul li
{
list-style:none;
padding:10;
float:left; /*Remove this comment to make it horizontal*/
}

body ul li:hover > ul
{
display:block;
position:absolute;
margin-top:10px;
top:20px;
width:30px;
left:80px;

}







</style>





</head>
<body>
<div>
<div>
<ul>
<li>Home</li>
<li>Gallery
<ul>
<li>Img1</li>
<li>img2</li>
</ul>



</li>
<li>ContactUs</li>
</ul>
</div>
</div>

</body>
</html>

Vertical Menu With Horizontal SubMenus USING CSS : VERY BASIC

<html>
<head>
<style>

body ul ul
{
display:none;
background-color:green;
}

body ul li
{
list-style:none;
padding:10;


}

body ul li:hover >   ul
{


display:inline;
}
body ul li:hover > ul li
{
height:500px;
display:inline;

}






</style>





</head>
<body>
<div>
<div>
<ul>
<li>Home</li>
<li>Gallery

<ul>
<li>Img1</li>
<li>Img2</li>



</ul>



</li>
<li>ContactUs</li>
</ul>
</div>
</div>

</body>
</html>