using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace file
{
class Program
{
static void Main(string[] args)
{
Thread t = new Thread(WriteY);
t.Start(); // Run WriteY on the new thread
while (true) Console.Write ("x"); // Write 'x' forever
}
static void WriteY()
{
while (true) Console.Write ("y"); // Write 'y' forever
}
}
}
OUTPUT
Multithreading
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace filestream
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
public delegate void new_foo_delegate();
void new_foo()
{
textBox1.Text = "Hullo";
}
void foo()
{
textBox1.Invoke(new new_foo_delegate(new_foo));
}
private void button1_Click(object sender, EventArgs e)
{
Thread t=new Thread(new ThreadStart(foo));
t.Start();
}
}
}
OUTPUT
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace file
{
class Program
{
static void Main(string[] args)
{
Thread t = new Thread(WriteY);
t.Start(); // Run WriteY on the new thread
while (true) Console.Write ("x"); // Write 'x' forever
}
static void WriteY()
{
while (true) Console.Write ("y"); // Write 'y' forever
}
}
}
OUTPUT
Multithreading
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace filestream
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
public delegate void new_foo_delegate();
void new_foo()
{
textBox1.Text = "Hullo";
}
void foo()
{
textBox1.Invoke(new new_foo_delegate(new_foo));
}
private void button1_Click(object sender, EventArgs e)
{
Thread t=new Thread(new ThreadStart(foo));
t.Start();
}
}
}
OUTPUT