Lecture 16: Multithreaded Programming. public partial class Form1 : Form { Thread ct; Thread rt; public static int circle_sleep = 0; public static int.

Slides:



Advertisements
Similar presentations
The Important Thing About By. The Important Thing About ******** The important thing about ***** is *****. It is true s/he can *****, *****, and *****.
Advertisements

Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
For(int i = 1; i
Nov 2005 MSc Slide 1 - Another Example of a Structural Pattern Alternative way of adding Functionality to an existing class (alternative to a derived class)
Software Engineering Implementation Lecture 3 ASPI8-4 Anders P. Ravn, Feb 2004.
1 CSC241: Object Oriented Programming Lecture No 21.
EC-241 Object-Oriented Programming
 2007 Dr. Natheer Khasawneh. Chapter 13. Graphical User Interface Concepts: Part 1.
02/05/2008CSCI 315 Operating Systems Design1 Java Threads Notice: The slides for this lecture have been largely based on those accompanying an earlier.
Using TCP sockets in Java Created by M Bateman, A Ruddle & C Allison As part of the TCP View project.
Lecture 4 Thread Concepts. Thread Definition A thread is a lightweight process (LWP) which accesses a shared address space provided by by the parent process.
02/05/2007CSCI 315 Operating Systems Design1 Java Threads Notice: The slides for this lecture have been largely based on those accompanying the textbook.
16-Jun-15 Producer-Consumer An example of using Threads.
CS220 Software Development Lecture: Multi-threading A. O’Riordan, 2009.
02/02/2004CSCI 315 Operating Systems Design1 Java Threads Notice: The slides for this lecture have been largely based on those accompanying the textbook.
28-Jun-15 Producer-Consumer An example of using Threads.
16-Aug-15 Java Puzzlers From the book Java Puzzlers by Joshua Bloch and Neal Gafter.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
Dr Dat Tran - Week 4 Lecture Notes 1 MenuStrip Programming Graphical User Interfaces PG (7110) University of Canberra School of Information Sciences &
Object Oriented Programming Graphical User Interfaces Dr. Mike Spann
Chapter 13 Working with Threads. Copyright 2006 Thomas P. Skinner2 Other Reference The book Programming Microsoft.NET by Jeff Prosise. Chapter 14 is excellent.
Data Binding to Controls Programming in C# Data Binding to Controls CSE 494R (proposed course for 459 Programming in C#) Prof. Roger Crawfis.
Lecture 8 Building an MDI Application. Introduction The MDI (Multiple Document Interface) provides a way to display multiple (child) windows forms inside.
Events and Timers. Event handlers ScratchC#/VS 2 Script == event handler.
Lecture 4 Advanced Topics Devi, Erick, Reddy. » Declare dynamic component, an example: ˃Create a button Button newBtn = new Button(); ˃Create an array.
Object Oriented Programming Multithreading Dr. Mike Spann
Object Oriented Programming Graphics and Multimedia Dr. Mike Spann
Copyright © 2006 Thomas P. Skinner1 Chapter 5 Indexers, Interfaces, and Enumerators.
Animation and Double-Buffering. The animation methods described here are based on standard techniques of double-buffering applicable to most high-level.
Session 08: Architecture Controllers or Managers Graphical User Interface (GUI) FEN AK - IT Softwarekonstruktion.
Dr Dat Tran - Week 1 Lecture Notes 1 Windows Forms Programming Graphical User Interfaces PG (7110) University of Canberra School of Information Sciences.
Dr Dat Tran - Week 4 Lecture Notes 1 ToolStrip Programming Graphical User Interfaces PG (7110) University of Canberra School of Information Sciences &
REVIEW On Friday we explored Client-Server Applications with Sockets. Servers must create a ServerSocket object on a specific Port #. They then can wait.
Lecture 2 Foundations and Definitions Processes/Threads.
By Szeto CYVisual C# Text form1Clock (label1) lblHH00 (label2) lblMM00 (label3) lblSS00 label4: label5: timer1Interval 500 Enabled true 按照下表,更改各控制項.
.NET 2.0 and Visual Studio 2005 SigWin Outline Language enhancements in C# Language enhancements in C# –Generics –Partial types –Anonymous methods.
Sample Application Multi Layered Architecture (n-tier): –Graphical User Interface (GUI): Forms, components, controls The Visual Designer in Visual Studio.
Multi-Client/Server GUI Application. Overview As part of the TCP.
Li Tak Sing COMPS311F. Case study: consumers and producers A fixed size buffer which can hold at most certain integers. A number of producers which generate.
Lecture 6: Advanced GUI Controls. Up to now we have used simple controls such as buttons and textboxes. Now we will review some interactive (e.g. dialog)
Command Object’s ExecuteNonQuery Method ISYS 512.

1 Graphic Device Interface (GDI). 2 Class Form A Form is a representation of any window displayed in your application. The Form class can be used to create.
IAsyncResult ar = BeginSomething(…); // Do other work, checking ar.IsCompleted int result = EndSomething(ar);
Dr Dat Tran - Week 2 Lecture Notes 1 Forms Programming Graphical User Interfaces PG (7110) University of Canberra School of Information Sciences & Engineering.
[ServiceContract] public interface IJokeOfTheDayService { [OperationContract] string GetJoke(int jokeStrength); }
Objects and Classes Continued Engineering 1D04, Teaching Session 10.
State Design Pattern. Behavioral Pattern Allows object to alter its behavior when internal state changes Uses Polymorphism to define different behaviors.
Java Producer-Consumer Monitor From: Concurrent Programming: The Java Programming Language By Steven J. Hartley Oxford University Press, 1998.
6.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Module 6: Process Synchronization Codes.
TreeBag a BST implementation. Example class - TreeBag  remember Bag?  collection of items, order does not matter  repeated items allowed public void.
WebClient client; 10 // Constructor public MainPage() { InitializeComponent(); client = new WebClient(); client.DownloadStringCompleted.
Lecture 14: File I/O Common Dialogs Toolbox Widgets.
Architecture Multi Layered Architecture (n-tier): Application: Model Controllers Database Access Graphical User Interface (GUI): Forms, components, controls.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
33) static void Main() { Action operations = MathOperations.MultiplyByTwo; operations += MathOperations.Square; ProcessAndDisplayNumber(operations, 2.0);
Threads b A thread is a flow of control in a program. b The Java Virtual Machine allows an application to have multiple threads of execution running concurrently.
1 Working with Controls at Run Time. 2 Objectives You will be able to Add controls to a Windows form at run time. Modify controls at run time.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Object Oriented Programming
Multithreaded Programming in Java
MUTENESS ASSİSTMENT 1)WHY CHOICE ? 2)ABOUT DESİGN 3)WHICH CODES USING
null, true, and false are also reserved.
class PrintOnetoTen { public static void main(String args[]) {
Object Oriented Programming
Web Service.
PreAP Computer Science Review Quiz 08
Creating Controls Dynamically in C#
label1 Name label2 Time (0-23) textBox1 textBox2 textBox3 button1
Poker2.jpg Poker14.jpg int num1, num2;
Presentation transcript:

Lecture 16: Multithreaded Programming

public partial class Form1 : Form { Thread ct; Thread rt; public static int circle_sleep = 0; public static int rectangle_sleep = 0; public Form1() { InitializeComponent(); circle_sleep = trkCircles.Value; rectangle_sleep = trkRectangles.Value; } private void CircleThread() { int size = 0; System.Random rnd = new Random(); Graphics paper; paper = pictureBox1.CreateGraphics(); Pen pen = new Pen(Color.White); do { size = rnd.Next(50) + 5; pen.Color = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255)); paper.DrawEllipse(pen, rnd.Next(295)+5, rnd.Next(295)+5, size, size); Thread.Sleep(circle_sleep); } while (true); }

private void btnCircles_Click(object sender, EventArgs e) { if (ct == null) { ct = new Thread(new ThreadStart(CircleThread)); ct.Start(); } else { try { ct.Abort(); } catch { } ct = null; } private void trkCircles_MouseUp(object sender, MouseEventArgs e) { circle_sleep = trkCircles.Value; } private void btnClear_Click(object sender, EventArgs e) { pictureBox1.Refresh(); } private void RectangleThread() { int size = 0; System.Random rnd = new Random(); Graphics paper; paper = pictureBox1.CreateGraphics(); Pen pen = new Pen(Color.White); do { size = rnd.Next(50) + 5; pen.Color = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255)); paper.DrawRectangle(pen, rnd.Next(295) + 5, rnd.Next(295) + 5, size, size); Thread.Sleep(rectangle_sleep); } while (true); }

private void btnRectangles_Click(object sender, EventArgs e) { if (rt == null) { rt = new Thread(new ThreadStart(RectangleThread)); rt.Start(); } else { try { rt.Abort(); } catch { } rt = null; } private void trackBar1_MouseUp(object sender, MouseEventArgs e) { rectangle_sleep = trkRectangles.Value; }