C# 문법 공부 : Threading - 3 pMonitor1 /* Monitor C#의 lock과 같이 특정 코드 블럭(Critiacal Section)을 배타적으로 Locking하는 기능을 가지고 있다. Monitor.Enter() 한 쓰레드만 블럭으로 들어가게 한다. Monitor.Exit() 락킹을 해제하여 다음 쓰레드가 블럭을 실행하게 한다. */using System;using System.Threading; namespace Threading;class pMonitor1 //Thread Monitor unsafe{ private int counter = 1000; private object lockOb..
C# 문법 공부 : Threading - 2 pTask1using System; using System.Threading.Tasks; namespace Threading;class Task1 //Task 클래스{ public void DoTest() { // Task.Factory를 이용하여 쓰레드 생성과 시작 // Task.Factory : Task 및 Task 인스턴스를 만들고 구성하는 팩터리 메서드에 대한 액세스를 제공 Task.Factory.StartNew(new Action(Run), null); Task.Factory.StartNew(new Action(Run), "1st"); Task.Factory..
C# 문법공부 Threading -1 Program2using System;using System.Threading;namespace Threading;class Program2 //동일 클래스 안의 Run() 메서드를 실행하는 쓰레드를 하나 생성한 후 실행시키는 예제{ public void DoTest() { Thread t1 = new Thread(new ThreadStart(Run)); // 새로운 쓰레드에서 Run() 실행 t1.Start(); Run(); // 메인쓰레드에서 Run() 실행 } void Run() { Console.WriteLine("Thread#{0}: Begin", Thread...
ThreadingFormusing System;namespace ThreadingForm;static class Program{ /// /// The main entry point for the application. /// [STAThread] static void Main() { // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); //Applicati..
WindowsForms FORM1using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.IO;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace WindowsForms{ public partial class Form1 : Form { public Form1() { InitializeComponent(); // Form1_Load라는 ..
Timer Formusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace Timer{ public partial class Form1 : Form { public Form1() { InitializeComponent(); // Timer.Interval 이벤트 사이의 간격(밀리초)을 지정 // 타이머시간을 1초로 변경 ..