ARTICLE

Drawing Shapes using Threading

Posted by Indika M W Articles | Multithreading in C# October 25, 2002
This is simple multi-threading program that draws circles and rectangles. Each shape is handle by individual thread that created every time you press start button. Using sleep method on each thread we can change the speed of each shape.
Reader Level:
Download Files:
 

This is simple multi-threading program that draws circles and rectangles. Each shape is handle by individual thread that created every time you press start button. Using sleep method on each thread we can change the speed of each shape.

I have used VS.NET to implement this program. Double click on Thread_Example.Zip and extract all the files and folders to a folder in C drive.

Run the project using VS.NET:

Double click on ThreadTester.sln (Prject file). Then run the project (press F5). The Form1 will appear as shown below.

Run using command-line prompt.

Copy all the .cs files (From1.cs, Rectangle.cs, Circle.cs and Shapes.cs) in to a folder in C drive and comple it using

C:\FolderName> csc *.cs
This will create a Form1.exe file inside the folder. Then double click it run it.

 

  1. Select the shape from the drop down list: Rectangle or Circle
  2. Then choose the speed from the drop down list.
  3. Then choose a colour by clicking the colour button.
  4. Then press start, which will start the relevant shape.
  5. Press exit when you want to exit.

Login to add your contents and source code to this article
post comment
     

I want to download this source code.

Posted by Rajiv Ranjan Sharma Aug 18, 2009
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Get Career Advice from Experts
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.