Threading in C#
Programming April 30th, 2007What is Threading?
-Parallel execution of code pieces on CPU, commonly compiled codes started in a single thread but it is possible to create multi-threads within a program.
Why Threading?
-Because threading is really useful, and it is used in nearly all kind of serious softwares, threads enables us to do independent jobs simultaneously, and it is sometimes hard to handle, if it is done with experienced hands, it enhances the software greatly. I want to give a simple example, consider you want your program to check for available updates and install them without interrupting the user’s work. This is only done with threads, while user working with your software, another thread connects to Internet and checks available updates without blocking the current execution of the software.
A simple threading example with C# :
Thread test_thread;
public void Thread_Task()
{
for(int i=0;i<100:++i)
TextBox1.Text=Convert.ToString(i);
}
private void button1_Click(object sender, EventArgs e)
{
test_thread=new Thread(new ThreadStart(this.Thread_Task));
test_thread.IsBackground = true;
test_thread.Start();
}
In the above simple code piece, we created a thread object and a thread task function, then we assigned task function to thread object in a button_click function, then we started the thread, as you notice, if user clicks the button a new thread starts and show the value of i in the TextBox1 without blocking the program, user may continue working and at the same time values of i are showed in the TextBox1. This was a sample example to demonstrate threads created and used, besides there is a vast usage and restrictions for threads, for example there will be a problem what if two threads wants to access the same resource and wants to edit, there are lots of synchronization problems and techniques.
Some other posts that you may like :
Useful PHP scriptsBack to the work after a long break
Hacked : Apple TV now support USB Storage Expansion
What's Wrong With This Fluid?
LG 's 3G Video Phone Is Supporting Google
IBM Patents External DRAM Box
Sorting Algorithms
Mynet Hacked !
C# Mail Client & Sending Mail With C# .NET
Virtual Machine Simulator

























































November 2nd, 2008 at 6:56 pm
Hi guys,
I am new to this forum www.buraak.com and hope that you can
give me an advice on the forex - I am looking for an introduction
for beginners. I have already some knowledge about shares. (Hope this is the adequate category.)
Any help is so much appreciated. Most important question: can a noob make money on the forex exchange market?
Thanks,
Jim